@pequity/squirrel 6.0.12 → 6.0.14

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 (69) hide show
  1. package/dist/cjs/chunks/index.js +2645 -0
  2. package/dist/cjs/chunks/p-btn.types.js +3 -0
  3. package/dist/cjs/chunks/p-select.js +2 -2
  4. package/dist/cjs/index.js +49 -52
  5. package/dist/cjs/inputClasses.js +129 -0
  6. package/dist/cjs/inputClassesMixin.js +23 -19
  7. package/dist/cjs/p-btn.js +56 -57
  8. package/dist/cjs/p-input-search.js +3 -3
  9. package/dist/cjs/useInputClasses.js +19 -18
  10. package/dist/es/chunks/index.js +2646 -0
  11. package/dist/es/chunks/p-btn.types.js +4 -0
  12. package/dist/es/chunks/p-select.js +2 -2
  13. package/dist/es/index.js +75 -78
  14. package/dist/es/inputClasses.js +129 -0
  15. package/dist/es/inputClassesMixin.js +23 -19
  16. package/dist/es/p-btn.js +56 -57
  17. package/dist/es/p-input-search.js +3 -3
  18. package/dist/es/useInputClasses.js +23 -22
  19. package/dist/squirrel/components/p-btn/p-btn.types.d.ts +2 -1
  20. package/dist/squirrel/components/p-btn/p-btn.vue.d.ts +395 -17
  21. package/dist/squirrel/components/p-dropdown-select/p-dropdown-select.vue.d.ts +30 -22
  22. package/dist/squirrel/components/p-input/p-input.vue.d.ts +11 -7
  23. package/dist/squirrel/components/p-input-number/p-input-number.vue.d.ts +11 -7
  24. package/dist/squirrel/components/p-input-percent/p-input-percent.vue.d.ts +3 -3
  25. package/dist/squirrel/components/p-input-search/p-input-search.vue.d.ts +16 -12
  26. package/dist/squirrel/components/p-select/p-select.vue.d.ts +5 -5
  27. package/dist/squirrel/components/p-select-list/p-select-list.vue.d.ts +30 -22
  28. package/dist/squirrel/components/p-table-header-cell/p-table-header-cell.vue.d.ts +1 -1
  29. package/dist/squirrel/components/p-textarea/p-textarea.vue.d.ts +11 -7
  30. package/dist/squirrel/components/p-toggle/p-toggle.vue.d.ts +11 -7
  31. package/dist/squirrel/composables/useInputClasses.d.ts +3 -3
  32. package/dist/squirrel/index.d.ts +1 -0
  33. package/dist/squirrel/utils/index.d.ts +2 -2
  34. package/dist/squirrel/utils/inputClasses.d.ts +988 -0
  35. package/dist/squirrel/utils/inputClassesMixin.d.ts +12 -8
  36. package/dist/squirrel.css +15 -22
  37. package/package.json +22 -19
  38. package/squirrel/assets/squirrel.css +1 -1
  39. package/squirrel/components/p-action-bar/p-action-bar.stories.js +1 -2
  40. package/squirrel/components/p-btn/p-btn.spec.js +1 -1
  41. package/squirrel/components/p-btn/p-btn.types.ts +3 -1
  42. package/squirrel/components/p-btn/p-btn.vue +60 -74
  43. package/squirrel/components/p-file-upload/p-file-upload.spec.js +3 -8
  44. package/squirrel/components/p-file-upload/p-file-upload.vue +6 -16
  45. package/squirrel/components/p-inline-date-picker/p-inline-date-picker.spec.js +3 -10
  46. package/squirrel/components/p-input/p-input.spec.js +3 -8
  47. package/squirrel/components/p-input-number/p-input-number.spec.js +15 -18
  48. package/squirrel/components/p-input-percent/p-input-percent.spec.js +3 -8
  49. package/squirrel/components/p-input-percent/p-input-percent.vue +3 -3
  50. package/squirrel/components/p-input-search/p-input-search.vue +4 -4
  51. package/squirrel/components/p-select/p-select.spec.js +28 -34
  52. package/squirrel/components/p-select/p-select.vue +4 -4
  53. package/squirrel/components/p-tabs/p-tabs.stories.js +2 -2
  54. package/squirrel/components/p-textarea/p-textarea.spec.js +3 -8
  55. package/squirrel/composables/useInputClasses.spec.js +138 -77
  56. package/squirrel/composables/useInputClasses.ts +25 -39
  57. package/squirrel/index.ts +1 -0
  58. package/squirrel/utils/index.ts +3 -36
  59. package/squirrel/utils/inputClasses.ts +130 -0
  60. package/squirrel/utils/inputClassesMixin.spec.js +153 -64
  61. package/squirrel/utils/inputClassesMixin.ts +26 -43
  62. package/dist/cjs/inputClassesShared.js +0 -76
  63. package/dist/es/inputClassesShared.js +0 -76
  64. package/dist/squirrel/utils/inputClassesShared.d.ts +0 -45
  65. package/squirrel/assets/file-upload-drag-over-icon.svg +0 -5
  66. package/squirrel/assets/file-upload-upload-icon.svg +0 -5
  67. package/squirrel/assets/file-upload-x-icon-hover.svg +0 -8
  68. package/squirrel/assets/file-upload-x-icon.svg +0 -8
  69. package/squirrel/utils/inputClassesShared.ts +0 -75
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ const SIZES = ["sm", "md", "lg"];
3
+ exports.SIZES = SIZES;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const vue = require("vue");
3
+ const pBtn_types = require("./p-btn.types.js");
3
4
  const useInputClasses = require("../useInputClasses.js");
4
- const inputClassesShared = require("../inputClassesShared.js");
5
5
  const _hoisted_1 = ["data-has-error"];
6
6
  const _hoisted_2 = ["value"];
7
7
  const _hoisted_3 = ["value"];
@@ -37,7 +37,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
37
37
  type: String,
38
38
  default: "md",
39
39
  validator(value) {
40
- return Object.keys(inputClassesShared.INPUT_SIZES).includes(value);
40
+ return pBtn_types.SIZES.includes(value);
41
41
  }
42
42
  },
43
43
  itemText: {
package/dist/cjs/index.js CHANGED
@@ -13,13 +13,12 @@ const pDrawer = require("./p-drawer.js");
13
13
  const pDropdown = require("./p-dropdown.js");
14
14
  const pDropdownSelect_vue_vue_type_script_setup_true_lang = require("./chunks/p-dropdown-select.js");
15
15
  const vue = require("vue");
16
- const pFileUpload$1 = require("./p-file-upload.js");
16
+ const pFileUpload = require("./p-file-upload.js");
17
+ const pIcon_vue_vue_type_script_setup_true_lang = require("./chunks/p-icon.js");
17
18
  const useInputClasses = require("./useInputClasses.js");
18
19
  const lodashEs = require("lodash-es");
19
20
  const vueToastification = require("vue-toastification");
20
- const _pluginVue_exportHelper = require("./chunks/_plugin-vue_export-helper.js");
21
21
  const pIcon = require("./p-icon.js");
22
- const pIcon_vue_vue_type_script_setup_true_lang = require("./chunks/p-icon.js");
23
22
  const pInfoIcon_vue_vue_type_script_setup_true_lang = require("./chunks/p-info-icon.js");
24
23
  const pInlineDatePicker_vue_vue_type_script_setup_true_lang = require("./chunks/p-inline-date-picker.js");
25
24
  const pInput = require("./p-input.js");
@@ -46,6 +45,7 @@ const pSkeletonLoader = require("./p-skeleton-loader.js");
46
45
  const pTable$1 = require("./p-table.js");
47
46
  const usePTableColResize = require("./usePTableColResize.js");
48
47
  const pTableHeaderCell = require("./p-table-header-cell.js");
48
+ const _pluginVue_exportHelper = require("./chunks/_plugin-vue_export-helper.js");
49
49
  const usePTableRowVirtualizer = require("./usePTableRowVirtualizer.js");
50
50
  const pTableFilterIcon = require("./p-table-filter-icon.js");
51
51
  const pTableLoader_vue_vue_type_script_setup_true_lang = require("./chunks/p-table-loader.js");
@@ -55,18 +55,17 @@ const pTabs_vue_vue_type_script_setup_true_lang = require("./chunks/p-tabs.js");
55
55
  const pTextarea = require("./p-textarea.js");
56
56
  const pToggle = require("./p-toggle.js");
57
57
  const config = require("./config.js");
58
+ const pBtn_types = require("./chunks/p-btn.types.js");
58
59
  const currency = require("./currency.js");
59
60
  const dom = require("./dom.js");
60
61
  const inputClassesMixin = require("./inputClassesMixin.js");
61
- const inputClassesShared = require("./inputClassesShared.js");
62
62
  const listKeyboardNavigation = require("./listKeyboardNavigation.js");
63
63
  const number = require("./number.js");
64
64
  const object = require("./object.js");
65
65
  const pagination = require("./pagination.js");
66
66
  const sanitization = require("./sanitization.js");
67
67
  const tailwind = require("./tailwind.js");
68
- const _imports_0$1 = "data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M5.8335%206.25016L10.0002%202.0835L14.1668%206.25016'%20stroke='%23767189'%20stroke-width='1.25'%20/%3e%3cpath%20d='M10%202.0835V13.7502'%20stroke='%23767189'%20stroke-width='1.25'%20/%3e%3cpath%20d='M2.91675%2015V18.3333H17.0834V15'%20stroke='%23767189'%20stroke-width='1.25'%20/%3e%3c/svg%3e";
69
- const _imports_1$1 = "data:image/svg+xml,%3csvg%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M33%2012H14V44H42V21L33%2012Z'%20stroke='%231A123B'%20stroke-width='3'%20/%3e%3cpath%20d='M9%2036H6V4H25L28%207'%20stroke='%231A123B'%20stroke-width='3'%20/%3e%3cpath%20d='M37%2030H19M28%2021V39'%20stroke='%231A123B'%20stroke-width='3'%20/%3e%3c/svg%3e";
68
+ const index = require("./chunks/index.js");
70
69
  const _hoisted_1$3 = ["data-has-error"];
71
70
  const _hoisted_2$3 = {
72
71
  key: 0,
@@ -181,7 +180,7 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
181
180
  }
182
181
  if (props.fileTypes.length === 0) ;
183
182
  else {
184
- const extension = pFileUpload$1.getFileExtension(fileName) ? `.${pFileUpload$1.getFileExtension(fileName)}` : "";
183
+ const extension = pFileUpload.getFileExtension(fileName) ? `.${pFileUpload.getFileExtension(fileName)}` : "";
185
184
  const isValidExtension = extension ? props.fileTypes.includes(extension) : false;
186
185
  if (!isValidExtension) {
187
186
  toast.error(`${extension} files are not allowed.`);
@@ -189,7 +188,7 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
189
188
  }
190
189
  }
191
190
  if ((file.size || 0) > props.maxSizeInBytes) {
192
- toast.error(`File size of ${fileName} exceeds ${pFileUpload$1.formatBytes(props.maxSizeInBytes)}.`);
191
+ toast.error(`File size of ${fileName} exceeds ${pFileUpload.formatBytes(props.maxSizeInBytes)}.`);
193
192
  continue;
194
193
  }
195
194
  res.push(file);
@@ -212,10 +211,10 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
212
211
  fileInputRef.value.value = "";
213
212
  }
214
213
  };
215
- const removeFile = (index) => {
216
- if (index in files.value) {
217
- const removedFile = files.value[index];
218
- files.value = files.value.filter((item, idx) => idx !== index);
214
+ const removeFile = (index2) => {
215
+ if (index2 in files.value) {
216
+ const removedFile = files.value[index2];
217
+ files.value = files.value.filter((item, idx) => idx !== index2);
219
218
  emit("file-removed", removedFile);
220
219
  }
221
220
  };
@@ -258,19 +257,21 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
258
257
  }, [
259
258
  !maxFilesReached.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$3, [
260
259
  !isDraggingOver.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$3, [
261
- _cache[4] || (_cache[4] = vue.createElementVNode("img", {
262
- src: _imports_0$1,
263
- class: "h-8 w-8"
264
- }, null, -1)),
260
+ vue.createVNode(pIcon_vue_vue_type_script_setup_true_lang._sfc_main, {
261
+ icon: "upload",
262
+ width: "32",
263
+ class: "text-p-gray-50"
264
+ }),
265
265
  vue.createElementVNode("div", _hoisted_4$3, [
266
266
  _cache[3] || (_cache[3] = vue.createTextVNode(" Drag or ")),
267
267
  vue.createElementVNode("span", _hoisted_5$3, "select " + vue.toDisplayString(fileWord.value), 1)
268
268
  ])
269
269
  ])) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_6$3, [
270
- _cache[5] || (_cache[5] = vue.createElementVNode("img", {
271
- src: _imports_1$1,
272
- class: "h-8 w-8"
273
- }, null, -1)),
270
+ vue.createVNode(pIcon_vue_vue_type_script_setup_true_lang._sfc_main, {
271
+ icon: "tdesign:drag-drop",
272
+ width: "32",
273
+ class: "text-primary"
274
+ }),
274
275
  vue.createElementVNode("div", _hoisted_7, "Drop " + vue.toDisplayString(fileWord.value), 1)
275
276
  ])),
276
277
  vue.createElementVNode("input", {
@@ -287,13 +288,13 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
287
288
  }, null, 40, _hoisted_8)
288
289
  ])) : vue.createCommentVNode("", true),
289
290
  vue.createElementVNode("div", _hoisted_9, [
290
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(files.value, (file, index) => {
291
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(files.value, (file, index2) => {
291
292
  return vue.openBlock(), vue.createElementBlock("div", {
292
- key: index,
293
+ key: index2,
293
294
  class: vue.normalizeClass([
294
295
  "flex cursor-default items-center justify-between",
295
- { "border-b border-dashed border-p-gray-30 pb-4": index !== files.value.length - 1 },
296
- { "mt-4": index !== 0 }
296
+ { "border-b border-dashed border-p-gray-30 pb-4": index2 !== files.value.length - 1 },
297
+ { "mt-4": index2 !== 0 }
297
298
  ]),
298
299
  onClick: _cache[0] || (_cache[0] = vue.withModifiers(() => {
299
300
  }, ["stop"]))
@@ -303,9 +304,15 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
303
304
  title: file.name
304
305
  }, vue.toDisplayString(file.name), 9, _hoisted_10),
305
306
  vue.createElementVNode("button", {
306
- class: "bg-file-upload-x-icon h-4 w-4 shrink-0 cursor-pointer",
307
- onClick: vue.withModifiers(($event) => removeFile(index), ["stop"])
308
- }, null, 8, _hoisted_11)
307
+ class: "h-5 shrink-0 cursor-pointer overflow-hidden",
308
+ onClick: vue.withModifiers(($event) => removeFile(index2), ["stop"])
309
+ }, [
310
+ vue.createVNode(pIcon_vue_vue_type_script_setup_true_lang._sfc_main, {
311
+ icon: "weui:close2-outlined",
312
+ width: "20",
313
+ class: "text-p-gray-60 hover:text-on-error"
314
+ })
315
+ ], 8, _hoisted_11)
309
316
  ], 2);
310
317
  }), 128))
311
318
  ])
@@ -315,12 +322,11 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
315
322
  }, vue.toDisplayString(__props.errorMsg), 3), [
316
323
  [vue.vShow, __props.errorMsg]
317
324
  ]),
318
- vue.createElementVNode("div", _hoisted_12, vue.toDisplayString(__props.multiple ? `Max ${__props.maxNumberOfFiles}` : "One") + " " + vue.toDisplayString(acceptFileTypes.value) + " " + vue.toDisplayString(__props.multiple ? "files" : "file") + " with size less than " + vue.toDisplayString(vue.unref(pFileUpload$1.formatBytes)(__props.maxSizeInBytes)) + " " + vue.toDisplayString(__props.multiple ? "each" : ""), 1)
325
+ vue.createElementVNode("div", _hoisted_12, vue.toDisplayString(__props.multiple ? `Max ${__props.maxNumberOfFiles}` : "One") + " " + vue.toDisplayString(acceptFileTypes.value) + " " + vue.toDisplayString(__props.multiple ? "files" : "file") + " with size less than " + vue.toDisplayString(vue.unref(pFileUpload.formatBytes)(__props.maxSizeInBytes)) + " " + vue.toDisplayString(__props.multiple ? "each" : ""), 1)
319
326
  ], 10, _hoisted_1$3);
320
327
  };
321
328
  }
322
329
  });
323
- const pFileUpload = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main$3, [["__scopeId", "data-v-216025be"]]);
324
330
  const _hoisted_1$2 = ["data-has-error"];
325
331
  const _hoisted_2$2 = { class: "text-p-purple-60" };
326
332
  const _hoisted_3$2 = { class: "flex flex-row" };
@@ -624,10 +630,10 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
624
630
  class: "truncate text-p-purple-60",
625
631
  title: vue.unref(string.toString)(vue.unref(getText)(row.index))
626
632
  }, [
627
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(text.splitStringForHighlight)(vue.unref(string.toString)(vue.unref(getText)(row.index)), vue.unref(search)), (str, index) => {
633
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(text.splitStringForHighlight)(vue.unref(string.toString)(vue.unref(getText)(row.index)), vue.unref(search)), (str, index2) => {
628
634
  return vue.openBlock(), vue.createElementBlock("span", {
629
- key: `${vue.unref(getValue)(row.index)}_${index}`,
630
- class: vue.normalizeClass({ "bg-p-blue-20": index === 1 })
635
+ key: `${vue.unref(getValue)(row.index)}_${index2}`,
636
+ class: vue.normalizeClass({ "bg-p-blue-20": index2 === 1 })
631
637
  }, vue.toDisplayString(str), 3);
632
638
  }), 128))
633
639
  ], 8, _hoisted_5$2)
@@ -715,9 +721,9 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
715
721
  ths
716
722
  });
717
723
  const tbodyElement = vue.ref(null);
718
- const updateThsRefs = (el, index) => {
724
+ const updateThsRefs = (el, index2) => {
719
725
  if (el instanceof Element) {
720
- ths.value[index] = el;
726
+ ths.value[index2] = el;
721
727
  }
722
728
  };
723
729
  const emitScroll = (e) => {
@@ -965,9 +971,9 @@ exports.PDatePicker = pDatePicker_vue_vue_type_script_setup_true_lang._sfc_main;
965
971
  exports.PDrawer = pDrawer;
966
972
  exports.PDropdown = pDropdown;
967
973
  exports.PDropdownSelect = pDropdownSelect_vue_vue_type_script_setup_true_lang._sfc_main;
974
+ exports.PIcon = pIcon_vue_vue_type_script_setup_true_lang._sfc_main;
968
975
  exports.useInputClasses = useInputClasses.useInputClasses;
969
976
  exports.P_ICON_ALIASES = pIcon.P_ICON_ALIASES;
970
- exports.PIcon = pIcon_vue_vue_type_script_setup_true_lang._sfc_main;
971
977
  exports.PInfoIcon = pInfoIcon_vue_vue_type_script_setup_true_lang._sfc_main;
972
978
  exports.PInlineDatePicker = pInlineDatePicker_vue_vue_type_script_setup_true_lang._sfc_main;
973
979
  exports.PInput = pInput;
@@ -1006,27 +1012,12 @@ exports.PTabs = pTabs_vue_vue_type_script_setup_true_lang._sfc_main;
1006
1012
  exports.PTextarea = pTextarea;
1007
1013
  exports.PToggle = pToggle;
1008
1014
  exports.squirrelTailwindConfig = config.squirrelTailwindConfig;
1015
+ exports.SIZES = pBtn_types.SIZES;
1009
1016
  exports.CURRENCY_INPUT_DEFAULTS = currency.CURRENCY_INPUT_DEFAULTS;
1010
1017
  exports.getNextActiveElement = dom.getNextActiveElement;
1011
1018
  exports.isElement = dom.isElement;
1012
1019
  exports.isVisible = dom.isVisible;
1013
1020
  exports.inputClassesMixin = inputClassesMixin;
1014
- exports.ERROR_MSG = inputClassesShared.ERROR_MSG;
1015
- exports.INPUT_BASE = inputClassesShared.INPUT_BASE;
1016
- exports.INPUT_ERROR = inputClassesShared.INPUT_ERROR;
1017
- exports.INPUT_NORMAL = inputClassesShared.INPUT_NORMAL;
1018
- exports.INPUT_SIZES = inputClassesShared.INPUT_SIZES;
1019
- exports.LABEL_BASE = inputClassesShared.LABEL_BASE;
1020
- exports.LABEL_REQUIRED = inputClassesShared.LABEL_REQUIRED;
1021
- exports.LABEL_SIZES = inputClassesShared.LABEL_SIZES;
1022
- exports.SELECT_ARROW = inputClassesShared.SELECT_ARROW;
1023
- exports.SELECT_BASE = inputClassesShared.SELECT_BASE;
1024
- exports.SELECT_SIZES = inputClassesShared.SELECT_SIZES;
1025
- exports.SPACING_LEFT = inputClassesShared.SPACING_LEFT;
1026
- exports.SPACING_PREFIX = inputClassesShared.SPACING_PREFIX;
1027
- exports.SPACING_RIGHT = inputClassesShared.SPACING_RIGHT;
1028
- exports.SPACING_SUFFIX = inputClassesShared.SPACING_SUFFIX;
1029
- exports.TEXTAREA_BASE = inputClassesShared.TEXTAREA_BASE;
1030
1021
  exports.setupListKeyboardNavigation = listKeyboardNavigation.setupListKeyboardNavigation;
1031
1022
  exports.toNumberOrNull = number.toNumberOrNull;
1032
1023
  exports.isObject = object.isObject;
@@ -1035,7 +1026,13 @@ exports.sanitizeUrl = sanitization.sanitizeUrl;
1035
1026
  exports.getColor = tailwind.getColor;
1036
1027
  exports.getColorDeep = tailwind.getColorDeep;
1037
1028
  exports.getScreen = tailwind.getScreen;
1038
- exports.PFileUpload = pFileUpload;
1029
+ exports.cn = index.M;
1030
+ exports.cnBase = index.N;
1031
+ exports.createTV = index.fe;
1032
+ exports.defaultConfig = index.ie;
1033
+ exports.tv = index.ce;
1034
+ exports.voidEmpty = index.x;
1035
+ exports.PFileUpload = _sfc_main$3;
1039
1036
  exports.PSelectList = _sfc_main$2;
1040
1037
  exports.PTable = pTable;
1041
1038
  exports.PTableSort = pTableSort;
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const index = require("./chunks/index.js");
4
+ const inputClasses = index.ce({
5
+ slots: {
6
+ input: "w-full rounded border-0 bg-surface text-night ring-1 ring-inset ring-p-gray-30 placeholder:text-p-gray-40 hover:ring-primary focus:outline-none focus:ring-2 focus:ring-primary disabled:cursor-default disabled:bg-p-blue-10 disabled:ring-p-gray-30 disabled:hover:ring-p-gray-30",
7
+ label: "mb-1 block font-medium",
8
+ errorMessage: "mt-1 text-xs text-on-error"
9
+ },
10
+ variants: {
11
+ size: {
12
+ sm: {
13
+ input: "h-8 pl-3 pr-3 text-sm",
14
+ label: "text-xs"
15
+ },
16
+ md: {
17
+ input: "h-10 pl-4 pr-4 text-base",
18
+ label: "text-sm"
19
+ },
20
+ lg: {
21
+ input: "h-12 pl-5 pr-5 text-lg",
22
+ label: "text-base"
23
+ }
24
+ },
25
+ prefix: {
26
+ true: "pl-8"
27
+ },
28
+ suffix: {
29
+ true: "pr-6"
30
+ },
31
+ required: {
32
+ true: {
33
+ label: `after:text-on-error after:content-["_*"]`
34
+ }
35
+ },
36
+ error: {
37
+ true: {
38
+ input: "ring-on-error hover:ring-on-error focus:ring-on-error"
39
+ }
40
+ },
41
+ rounded: {
42
+ true: {
43
+ input: "rounded-full"
44
+ }
45
+ }
46
+ },
47
+ compoundVariants: [
48
+ {
49
+ size: "sm",
50
+ prefix: true,
51
+ class: {
52
+ input: "pl-6"
53
+ }
54
+ },
55
+ {
56
+ size: "md",
57
+ prefix: true,
58
+ class: {
59
+ input: "pl-8"
60
+ }
61
+ },
62
+ {
63
+ size: "lg",
64
+ prefix: true,
65
+ class: {
66
+ input: "pl-12"
67
+ }
68
+ },
69
+ {
70
+ size: "sm",
71
+ suffix: true,
72
+ class: {
73
+ input: "pr-6"
74
+ }
75
+ },
76
+ {
77
+ size: "md",
78
+ suffix: true,
79
+ class: {
80
+ input: "pr-8"
81
+ }
82
+ },
83
+ {
84
+ size: "lg",
85
+ suffix: true,
86
+ class: {
87
+ input: "pr-12"
88
+ }
89
+ }
90
+ ],
91
+ defaultVariants: {
92
+ size: "md"
93
+ }
94
+ });
95
+ const textareaClasses = index.ce({
96
+ extend: inputClasses,
97
+ slots: {
98
+ input: "resize-y overflow-auto px-3 py-3"
99
+ },
100
+ variants: {
101
+ size: {
102
+ md: {
103
+ input: "h-auto"
104
+ }
105
+ }
106
+ }
107
+ });
108
+ const selectClasses = index.ce({
109
+ extend: inputClasses,
110
+ slots: {
111
+ input: "squirrel-bg-chevron-down appearance-none truncate bg-no-repeat"
112
+ },
113
+ variants: {
114
+ size: {
115
+ sm: {
116
+ input: "bg-[position:right_0.675rem_center] pr-8"
117
+ },
118
+ md: {
119
+ input: "bg-[position:right_1rem_center] pr-10"
120
+ },
121
+ lg: {
122
+ input: "bg-[position:right_1.25rem_center] pr-12"
123
+ }
124
+ }
125
+ }
126
+ });
127
+ exports.inputClasses = inputClasses;
128
+ exports.selectClasses = selectClasses;
129
+ exports.textareaClasses = textareaClasses;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
- const inputClassesShared = require("./inputClassesShared.js");
2
+ const pBtn_types = require("./chunks/p-btn.types.js");
3
+ const inputClasses = require("./inputClasses.js");
3
4
  const vue = require("vue");
4
5
  const inputClassesMixin = vue.defineComponent({
5
6
  props: {
@@ -7,7 +8,7 @@ const inputClassesMixin = vue.defineComponent({
7
8
  type: String,
8
9
  default: "md",
9
10
  validator(value) {
10
- return Object.keys(inputClassesShared.INPUT_SIZES).includes(value);
11
+ return pBtn_types.SIZES.includes(value);
11
12
  }
12
13
  },
13
14
  errorMsg: {
@@ -23,31 +24,34 @@ const inputClassesMixin = vue.defineComponent({
23
24
  default: false
24
25
  }
25
26
  },
26
- data() {
27
- return {
28
- errorMsgClasses: inputClassesShared.ERROR_MSG
29
- };
30
- },
31
27
  computed: {
28
+ allClasses() {
29
+ const { input, label, errorMessage } = inputClasses.inputClasses({
30
+ size: this.size,
31
+ prefix: !!this.$slots.prefix,
32
+ suffix: !!this.$slots.suffix,
33
+ required: this.required,
34
+ error: !!this.errorMsg,
35
+ rounded: this.rounded
36
+ });
37
+ return { input: input(), label: label(), errorMessage: errorMessage() };
38
+ },
32
39
  inputClasses() {
33
- const base = `${inputClassesShared.INPUT_BASE} ${inputClassesShared.INPUT_SIZES[this.size]}`;
34
- const spacingLeft = this.$slots.prefix ? inputClassesShared.SPACING_PREFIX[this.size] : inputClassesShared.SPACING_LEFT[this.size];
35
- const spacingRight = this.$slots.suffix ? inputClassesShared.SPACING_SUFFIX[this.size] : inputClassesShared.SPACING_RIGHT[this.size];
36
- const res = `${base} ${spacingLeft} ${spacingRight} ${this.errorMsg ? inputClassesShared.INPUT_ERROR : inputClassesShared.INPUT_NORMAL}${this.rounded ? " rounded-full" : ""}`;
37
- return res;
40
+ return this.allClasses.input;
38
41
  },
39
42
  labelClasses() {
40
- const base = `${inputClassesShared.LABEL_BASE} ${inputClassesShared.LABEL_SIZES[this.size]}`;
41
- const res = this.required ? `${base} ${inputClassesShared.LABEL_REQUIRED}` : base;
42
- return res;
43
+ return this.allClasses.label;
44
+ },
45
+ errorMsgClasses() {
46
+ return this.allClasses.errorMessage;
43
47
  },
44
48
  selectClasses() {
45
- const res = `${this.inputClasses.replace(` ${inputClassesShared.SPACING_RIGHT[this.size]}`, "")} ${inputClassesShared.SELECT_BASE} ${inputClassesShared.SELECT_ARROW} ${inputClassesShared.SELECT_SIZES[this.size]}`;
46
- return res;
49
+ const { input } = inputClasses.selectClasses({ size: this.size, required: this.required, error: !!this.errorMsg });
50
+ return input();
47
51
  },
48
52
  textareaClasses() {
49
- const res = `${this.inputClasses} ${inputClassesShared.TEXTAREA_BASE}`;
50
- return res;
53
+ const { input } = inputClasses.textareaClasses({ required: this.required, error: !!this.errorMsg });
54
+ return input();
51
55
  }
52
56
  }
53
57
  });
package/dist/cjs/p-btn.js CHANGED
@@ -1,58 +1,60 @@
1
1
  "use strict";
2
+ const pBtn_types = require("./chunks/p-btn.types.js");
2
3
  const pRingLoader_vue_vue_type_script_setup_true_lang = require("./chunks/p-ring-loader.js");
3
4
  const link = require("./link.js");
4
5
  const sanitization = require("./sanitization.js");
6
+ const index = require("./chunks/index.js");
5
7
  const vue = require("vue");
6
8
  const vueRouter = require("vue-router");
7
9
  const _pluginVue_exportHelper = require("./chunks/_plugin-vue_export-helper.js");
8
- const BUTTON_TYPES = {
9
- PRIMARY: "primary",
10
- SECONDARY: "secondary",
11
- PRIMARY_OUTLINE: "primary-outline",
12
- SECONDARY_OUTLINE: "secondary-outline",
13
- SECONDARY_OUTLINE_BLUE: "secondary-outline-blue",
14
- ERROR: "error",
15
- SUCCESS: "success",
16
- PRIMARY_LINK: "primary-link",
17
- SECONDARY_GHOST: "secondary-ghost",
18
- SECONDARY_GHOST_DARK: "secondary-ghost-dark"
10
+ const btnClasses = {
11
+ slots: {
12
+ button: "relative inline-block rounded font-medium outline-none disabled:pointer-events-none disabled:cursor-default disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:cursor-default aria-disabled:opacity-50",
13
+ loader: "absolute bottom-0 left-0 right-0 top-0 flex items-center justify-center font-medium"
14
+ },
15
+ variants: {
16
+ type: {
17
+ primary: {
18
+ button: "bg-primary text-surface hover:bg-accent active:bg-p-blue-80",
19
+ loader: "text-surface"
20
+ },
21
+ secondary: {
22
+ button: "bg-p-gray-20 hover:bg-p-gray-30 active:bg-p-gray-40",
23
+ loader: "text-p-purple-60"
24
+ },
25
+ "primary-outline": {
26
+ button: "bg-p-blue-10 text-p-purple-60 ring-1 ring-inset ring-p-purple-60 hover:bg-p-gray-20",
27
+ loader: "text-p-purple-60"
28
+ },
29
+ "secondary-outline": {
30
+ button: "bg-surface text-p-purple-60 ring-1 ring-inset ring-p-gray-30 hover:bg-p-blue-10 aria-selected:bg-p-blue-10",
31
+ loader: "text-p-purple-60"
32
+ },
33
+ "secondary-outline-blue": {
34
+ button: "bg-surface text-p-purple-60 ring-1 ring-inset ring-p-gray-30 hover:bg-p-blue-10 aria-selected:bg-p-blue-15 aria-selected:text-p-blue-60",
35
+ loader: "text-p-purple-60"
36
+ },
37
+ error: { button: "bg-p-red-40 text-white hover:bg-p-red-50", loader: "text-white" },
38
+ success: { button: "bg-p-green-40 text-white hover:bg-p-green-50", loader: "text-white" },
39
+ "primary-link": { button: "bg-transparent text-primary underline hover:text-accent", loader: "text-p-blue-60" },
40
+ "secondary-ghost": { button: "text-on-surface hover:bg-p-gray-20", loader: "text-p-purple-60" },
41
+ "secondary-ghost-dark": { button: "text-white hover:bg-p-purple-50", loader: "text-p-blue-15" }
42
+ },
43
+ size: {
44
+ sm: { button: "px-2 py-1 text-sm" },
45
+ md: { button: "px-6 py-2 text-base" },
46
+ lg: { button: "px-6 py-2.5 text-lg" }
47
+ }
48
+ },
49
+ defaultVariants: {
50
+ type: "primary",
51
+ size: "md"
52
+ }
19
53
  };
54
+ const btn = index.ce(btnClasses);
55
+ const BUTTON_TYPES = Object.keys(btnClasses.variants.type);
20
56
  const BUTTON_NATIVE_TYPES = ["button", "submit", "reset"];
21
- const DEFAULT_CLASSES = `relative inline-block outline-none disabled:opacity-50 disabled:cursor-default disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:cursor-default aria-disabled:pointer-events-none`;
22
- const BUTTON_CLASSES = {
23
- [BUTTON_TYPES.PRIMARY]: "text-surface bg-primary hover:bg-accent active:bg-p-blue-80",
24
- [BUTTON_TYPES.SECONDARY]: "bg-p-gray-20 hover:bg-p-gray-30 active:bg-p-gray-40",
25
- [BUTTON_TYPES.PRIMARY_OUTLINE]: "text-p-purple-60 bg-p-blue-10 ring-1 ring-inset ring-p-purple-60 hover:bg-p-gray-20",
26
- [BUTTON_TYPES.SECONDARY_OUTLINE]: "text-p-purple-60 bg-surface ring-1 ring-inset ring-p-gray-30 hover:bg-p-blue-10 aria-selected:bg-p-blue-10",
27
- [BUTTON_TYPES.SECONDARY_OUTLINE_BLUE]: "text-p-purple-60 bg-surface ring-1 ring-inset ring-p-gray-30 hover:bg-p-blue-10 aria-selected:bg-p-blue-15 aria-selected:text-p-blue-60",
28
- [BUTTON_TYPES.ERROR]: "text-white bg-p-red-40 hover:bg-p-red-50",
29
- [BUTTON_TYPES.SUCCESS]: "text-white bg-p-green-40 hover:bg-p-green-50",
30
- [BUTTON_TYPES.PRIMARY_LINK]: "text-primary bg-transparent hover:text-accent underline",
31
- [BUTTON_TYPES.SECONDARY_GHOST]: "text-on-surface hover:bg-p-gray-20",
32
- [BUTTON_TYPES.SECONDARY_GHOST_DARK]: "text-white hover:bg-p-purple-50"
33
- };
34
- const BUTTON_SIZES = {
35
- sm: "py-1 px-2 rounded font-medium text-sm",
36
- md: "py-2 px-6 rounded font-medium text-base",
37
- lg: "py-3 px-6 rounded font-medium text-lg"
38
- };
39
- const LOADER_SIZES = {
40
- sm: 24,
41
- md: 30,
42
- lg: 40
43
- };
44
- const LOADER_COLORS = {
45
- [BUTTON_TYPES.PRIMARY]: "var(--color-p-blue-15)",
46
- [BUTTON_TYPES.SECONDARY]: "var(--color-p-purple-60)",
47
- [BUTTON_TYPES.PRIMARY_OUTLINE]: "var(--color-p-blue-60)",
48
- [BUTTON_TYPES.SECONDARY_OUTLINE]: "var(--color-p-purple-60)",
49
- [BUTTON_TYPES.SECONDARY_OUTLINE_BLUE]: "var(--color-p-purple-60)",
50
- [BUTTON_TYPES.ERROR]: "var(--color-p-blue-15)",
51
- [BUTTON_TYPES.SUCCESS]: "var(--color-p-blue-15)",
52
- [BUTTON_TYPES.PRIMARY_LINK]: "var(--color-p-blue-60)",
53
- [BUTTON_TYPES.SECONDARY_GHOST]: "var(--color-p-purple-60)",
54
- [BUTTON_TYPES.SECONDARY_GHOST_DARK]: "var(--color-p-blue-15)"
55
- };
57
+ const LOADER_SIZES = { sm: 24, md: 30, lg: 40 };
56
58
  const _sfc_main = vue.defineComponent({
57
59
  name: "PBtn",
58
60
  components: {
@@ -68,7 +70,7 @@ const _sfc_main = vue.defineComponent({
68
70
  type: String,
69
71
  default: "primary",
70
72
  validator(value) {
71
- return Object.values(BUTTON_TYPES).includes(value);
73
+ return BUTTON_TYPES.includes(value);
72
74
  }
73
75
  },
74
76
  /**
@@ -88,7 +90,7 @@ const _sfc_main = vue.defineComponent({
88
90
  type: String,
89
91
  default: "md",
90
92
  validator(value) {
91
- return Object.keys(BUTTON_SIZES).includes(value);
93
+ return pBtn_types.SIZES.includes(value);
92
94
  }
93
95
  },
94
96
  /**
@@ -116,13 +118,11 @@ const _sfc_main = vue.defineComponent({
116
118
  },
117
119
  computed: {
118
120
  classes() {
119
- return `${DEFAULT_CLASSES} ${BUTTON_SIZES[this.size]} ${BUTTON_CLASSES[this.type]}`;
121
+ const { button, loader } = btn({ type: this.type, size: this.size });
122
+ return { button: button(), loader: loader() };
120
123
  },
121
124
  loaderSize() {
122
125
  return Number(`${LOADER_SIZES[this.size]}`);
123
- },
124
- loaderColor() {
125
- return LOADER_COLORS[this.type];
126
126
  }
127
127
  },
128
128
  methods: {
@@ -136,7 +136,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
136
136
  return typeof _ctx.to === "string" && _ctx.isExternalLink(_ctx.to) ? (vue.openBlock(), vue.createElementBlock("a", vue.mergeProps({ key: 0 }, _ctx.$attrs, {
137
137
  href: _ctx.sanitizeUrl(_ctx.to),
138
138
  target: "_blank",
139
- class: _ctx.classes,
139
+ class: _ctx.classes.button,
140
140
  disabled: !!_ctx.$attrs.disabled ? true : null,
141
141
  "aria-disabled": !!_ctx.$attrs.disabled
142
142
  }), [
@@ -146,7 +146,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
146
146
  type: _ctx.to ? null : _ctx.nativeType,
147
147
  to: _ctx.to ? _ctx.to : null,
148
148
  "aria-selected": _ctx.selected,
149
- class: _ctx.classes
149
+ class: _ctx.classes.button
150
150
  }, _ctx.$attrs, {
151
151
  disabled: !!_ctx.$attrs.disabled || _ctx.loading ? true : null,
152
152
  "aria-disabled": _ctx.$attrs.disabled
@@ -159,10 +159,9 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
159
159
  ], 2),
160
160
  _ctx.loading ? (vue.openBlock(), vue.createBlock(_component_PRingLoader, {
161
161
  key: 0,
162
- color: _ctx.loaderColor,
163
162
  size: _ctx.loaderSize,
164
- class: "absolute bottom-0 left-0 right-0 top-0 flex items-center justify-center"
165
- }, null, 8, ["color", "size"])) : vue.createCommentVNode("", true)
163
+ class: vue.normalizeClass(_ctx.classes.loader)
164
+ }, null, 8, ["size", "class"])) : vue.createCommentVNode("", true)
166
165
  ]),
167
166
  _: 3
168
167
  }, 16, ["type", "to", "aria-selected", "class", "disabled", "aria-disabled"]));
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
+ const pBtn_types = require("./chunks/p-btn.types.js");
2
3
  const pInput = require("./p-input.js");
3
- const inputClassesShared = require("./inputClassesShared.js");
4
4
  const vue = require("vue");
5
5
  const _pluginVue_exportHelper = require("./chunks/_plugin-vue_export-helper.js");
6
6
  const _sfc_main = vue.defineComponent({
@@ -18,7 +18,7 @@ const _sfc_main = vue.defineComponent({
18
18
  type: String,
19
19
  default: "md",
20
20
  validator(value) {
21
- return Object.keys(inputClassesShared.INPUT_SIZES).includes(value);
21
+ return pBtn_types.SIZES.includes(value);
22
22
  }
23
23
  },
24
24
  showEnterIcon: {
@@ -108,5 +108,5 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
108
108
  _: 1
109
109
  }, 16, ["modelValue", "size", "onKeydown"]);
110
110
  }
111
- const PInputSearch = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-2674242c"]]);
111
+ const PInputSearch = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-78b7a6f8"]]);
112
112
  module.exports = PInputSearch;