@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
package/dist/es/p-btn.js CHANGED
@@ -1,57 +1,59 @@
1
+ import { S as SIZES } from "./chunks/p-btn.types.js";
1
2
  import { _ as _sfc_main$1 } from "./chunks/p-ring-loader.js";
2
3
  import { isExternalLink } from "./link.js";
3
4
  import { sanitizeUrl } from "./sanitization.js";
5
+ import { c as ce } from "./chunks/index.js";
4
6
  import { defineComponent, resolveComponent, createElementBlock, createBlock, openBlock, mergeProps, renderSlot, resolveDynamicComponent, withCtx, createElementVNode, createCommentVNode, normalizeClass } from "vue";
5
7
  import { RouterLink } from "vue-router";
6
8
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
7
- const BUTTON_TYPES = {
8
- PRIMARY: "primary",
9
- SECONDARY: "secondary",
10
- PRIMARY_OUTLINE: "primary-outline",
11
- SECONDARY_OUTLINE: "secondary-outline",
12
- SECONDARY_OUTLINE_BLUE: "secondary-outline-blue",
13
- ERROR: "error",
14
- SUCCESS: "success",
15
- PRIMARY_LINK: "primary-link",
16
- SECONDARY_GHOST: "secondary-ghost",
17
- SECONDARY_GHOST_DARK: "secondary-ghost-dark"
9
+ const btnClasses = {
10
+ slots: {
11
+ 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",
12
+ loader: "absolute bottom-0 left-0 right-0 top-0 flex items-center justify-center font-medium"
13
+ },
14
+ variants: {
15
+ type: {
16
+ primary: {
17
+ button: "bg-primary text-surface hover:bg-accent active:bg-p-blue-80",
18
+ loader: "text-surface"
19
+ },
20
+ secondary: {
21
+ button: "bg-p-gray-20 hover:bg-p-gray-30 active:bg-p-gray-40",
22
+ loader: "text-p-purple-60"
23
+ },
24
+ "primary-outline": {
25
+ button: "bg-p-blue-10 text-p-purple-60 ring-1 ring-inset ring-p-purple-60 hover:bg-p-gray-20",
26
+ loader: "text-p-purple-60"
27
+ },
28
+ "secondary-outline": {
29
+ 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",
30
+ loader: "text-p-purple-60"
31
+ },
32
+ "secondary-outline-blue": {
33
+ 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",
34
+ loader: "text-p-purple-60"
35
+ },
36
+ error: { button: "bg-p-red-40 text-white hover:bg-p-red-50", loader: "text-white" },
37
+ success: { button: "bg-p-green-40 text-white hover:bg-p-green-50", loader: "text-white" },
38
+ "primary-link": { button: "bg-transparent text-primary underline hover:text-accent", loader: "text-p-blue-60" },
39
+ "secondary-ghost": { button: "text-on-surface hover:bg-p-gray-20", loader: "text-p-purple-60" },
40
+ "secondary-ghost-dark": { button: "text-white hover:bg-p-purple-50", loader: "text-p-blue-15" }
41
+ },
42
+ size: {
43
+ sm: { button: "px-2 py-1 text-sm" },
44
+ md: { button: "px-6 py-2 text-base" },
45
+ lg: { button: "px-6 py-2.5 text-lg" }
46
+ }
47
+ },
48
+ defaultVariants: {
49
+ type: "primary",
50
+ size: "md"
51
+ }
18
52
  };
53
+ const btn = ce(btnClasses);
54
+ const BUTTON_TYPES = Object.keys(btnClasses.variants.type);
19
55
  const BUTTON_NATIVE_TYPES = ["button", "submit", "reset"];
20
- 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`;
21
- const BUTTON_CLASSES = {
22
- [BUTTON_TYPES.PRIMARY]: "text-surface bg-primary hover:bg-accent active:bg-p-blue-80",
23
- [BUTTON_TYPES.SECONDARY]: "bg-p-gray-20 hover:bg-p-gray-30 active:bg-p-gray-40",
24
- [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",
25
- [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",
26
- [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",
27
- [BUTTON_TYPES.ERROR]: "text-white bg-p-red-40 hover:bg-p-red-50",
28
- [BUTTON_TYPES.SUCCESS]: "text-white bg-p-green-40 hover:bg-p-green-50",
29
- [BUTTON_TYPES.PRIMARY_LINK]: "text-primary bg-transparent hover:text-accent underline",
30
- [BUTTON_TYPES.SECONDARY_GHOST]: "text-on-surface hover:bg-p-gray-20",
31
- [BUTTON_TYPES.SECONDARY_GHOST_DARK]: "text-white hover:bg-p-purple-50"
32
- };
33
- const BUTTON_SIZES = {
34
- sm: "py-1 px-2 rounded font-medium text-sm",
35
- md: "py-2 px-6 rounded font-medium text-base",
36
- lg: "py-3 px-6 rounded font-medium text-lg"
37
- };
38
- const LOADER_SIZES = {
39
- sm: 24,
40
- md: 30,
41
- lg: 40
42
- };
43
- const LOADER_COLORS = {
44
- [BUTTON_TYPES.PRIMARY]: "var(--color-p-blue-15)",
45
- [BUTTON_TYPES.SECONDARY]: "var(--color-p-purple-60)",
46
- [BUTTON_TYPES.PRIMARY_OUTLINE]: "var(--color-p-blue-60)",
47
- [BUTTON_TYPES.SECONDARY_OUTLINE]: "var(--color-p-purple-60)",
48
- [BUTTON_TYPES.SECONDARY_OUTLINE_BLUE]: "var(--color-p-purple-60)",
49
- [BUTTON_TYPES.ERROR]: "var(--color-p-blue-15)",
50
- [BUTTON_TYPES.SUCCESS]: "var(--color-p-blue-15)",
51
- [BUTTON_TYPES.PRIMARY_LINK]: "var(--color-p-blue-60)",
52
- [BUTTON_TYPES.SECONDARY_GHOST]: "var(--color-p-purple-60)",
53
- [BUTTON_TYPES.SECONDARY_GHOST_DARK]: "var(--color-p-blue-15)"
54
- };
56
+ const LOADER_SIZES = { sm: 24, md: 30, lg: 40 };
55
57
  const _sfc_main = defineComponent({
56
58
  name: "PBtn",
57
59
  components: {
@@ -67,7 +69,7 @@ const _sfc_main = defineComponent({
67
69
  type: String,
68
70
  default: "primary",
69
71
  validator(value) {
70
- return Object.values(BUTTON_TYPES).includes(value);
72
+ return BUTTON_TYPES.includes(value);
71
73
  }
72
74
  },
73
75
  /**
@@ -87,7 +89,7 @@ const _sfc_main = defineComponent({
87
89
  type: String,
88
90
  default: "md",
89
91
  validator(value) {
90
- return Object.keys(BUTTON_SIZES).includes(value);
92
+ return SIZES.includes(value);
91
93
  }
92
94
  },
93
95
  /**
@@ -115,13 +117,11 @@ const _sfc_main = defineComponent({
115
117
  },
116
118
  computed: {
117
119
  classes() {
118
- return `${DEFAULT_CLASSES} ${BUTTON_SIZES[this.size]} ${BUTTON_CLASSES[this.type]}`;
120
+ const { button, loader } = btn({ type: this.type, size: this.size });
121
+ return { button: button(), loader: loader() };
119
122
  },
120
123
  loaderSize() {
121
124
  return Number(`${LOADER_SIZES[this.size]}`);
122
- },
123
- loaderColor() {
124
- return LOADER_COLORS[this.type];
125
125
  }
126
126
  },
127
127
  methods: {
@@ -135,7 +135,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
135
135
  return typeof _ctx.to === "string" && _ctx.isExternalLink(_ctx.to) ? (openBlock(), createElementBlock("a", mergeProps({ key: 0 }, _ctx.$attrs, {
136
136
  href: _ctx.sanitizeUrl(_ctx.to),
137
137
  target: "_blank",
138
- class: _ctx.classes,
138
+ class: _ctx.classes.button,
139
139
  disabled: !!_ctx.$attrs.disabled ? true : null,
140
140
  "aria-disabled": !!_ctx.$attrs.disabled
141
141
  }), [
@@ -145,7 +145,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
145
145
  type: _ctx.to ? null : _ctx.nativeType,
146
146
  to: _ctx.to ? _ctx.to : null,
147
147
  "aria-selected": _ctx.selected,
148
- class: _ctx.classes
148
+ class: _ctx.classes.button
149
149
  }, _ctx.$attrs, {
150
150
  disabled: !!_ctx.$attrs.disabled || _ctx.loading ? true : null,
151
151
  "aria-disabled": _ctx.$attrs.disabled
@@ -158,10 +158,9 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
158
158
  ], 2),
159
159
  _ctx.loading ? (openBlock(), createBlock(_component_PRingLoader, {
160
160
  key: 0,
161
- color: _ctx.loaderColor,
162
161
  size: _ctx.loaderSize,
163
- class: "absolute bottom-0 left-0 right-0 top-0 flex items-center justify-center"
164
- }, null, 8, ["color", "size"])) : createCommentVNode("", true)
162
+ class: normalizeClass(_ctx.classes.loader)
163
+ }, null, 8, ["size", "class"])) : createCommentVNode("", true)
165
164
  ]),
166
165
  _: 3
167
166
  }, 16, ["type", "to", "aria-selected", "class", "disabled", "aria-disabled"]));
@@ -1,5 +1,5 @@
1
+ import { S as SIZES } from "./chunks/p-btn.types.js";
1
2
  import PInput from "./p-input.js";
2
- import { INPUT_SIZES } from "./inputClassesShared.js";
3
3
  import { defineComponent, resolveComponent, resolveDirective, createBlock, openBlock, mergeProps, withKeys, withCtx, withDirectives, createCommentVNode, createElementBlock, normalizeClass, createElementVNode } from "vue";
4
4
  import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
5
5
  const _sfc_main = defineComponent({
@@ -17,7 +17,7 @@ const _sfc_main = defineComponent({
17
17
  type: String,
18
18
  default: "md",
19
19
  validator(value) {
20
- return Object.keys(INPUT_SIZES).includes(value);
20
+ return SIZES.includes(value);
21
21
  }
22
22
  },
23
23
  showEnterIcon: {
@@ -107,7 +107,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
107
107
  _: 1
108
108
  }, 16, ["modelValue", "size", "onKeydown"]);
109
109
  }
110
- const PInputSearch = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-2674242c"]]);
110
+ const PInputSearch = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-78b7a6f8"]]);
111
111
  export {
112
112
  PInputSearch as default
113
113
  };
@@ -1,4 +1,4 @@
1
- import { INPUT_BASE, INPUT_SIZES, SPACING_PREFIX, SPACING_LEFT, SPACING_SUFFIX, SPACING_RIGHT, INPUT_ERROR, INPUT_NORMAL, LABEL_BASE, LABEL_SIZES, LABEL_REQUIRED, SELECT_BASE, SELECT_ARROW, SELECT_SIZES, TEXTAREA_BASE, ERROR_MSG } from "./inputClassesShared.js";
1
+ import { inputClasses, selectClasses, textareaClasses } from "./inputClasses.js";
2
2
  import { ref, toRefs, computed } from "vue";
3
3
  const defaults = {
4
4
  size: ref("md"),
@@ -11,32 +11,33 @@ const defaults = {
11
11
  function useInputClasses(props) {
12
12
  const opts = { ...defaults, ...toRefs(props) };
13
13
  const { size, errorMsg, required, rounded, prefix, suffix } = opts;
14
- const inputClasses = computed(() => {
15
- const base = `${INPUT_BASE} ${INPUT_SIZES[size.value]}`;
16
- const spacingLeft = prefix.value ? SPACING_PREFIX[size.value] : SPACING_LEFT[size.value];
17
- const spacingRight = suffix.value ? SPACING_SUFFIX[size.value] : SPACING_RIGHT[size.value];
18
- const res = `${base} ${spacingLeft} ${spacingRight} ${errorMsg.value ? INPUT_ERROR : INPUT_NORMAL}${rounded.value ? " rounded-full" : ""}`;
19
- return res;
14
+ const allClasses = computed(() => {
15
+ const { input, label, errorMessage } = inputClasses({
16
+ size: size.value,
17
+ prefix: prefix.value,
18
+ suffix: suffix.value,
19
+ required: required.value,
20
+ error: !!errorMsg.value,
21
+ rounded: rounded.value
22
+ });
23
+ return { input: input(), label: label(), errorMessage: errorMessage() };
20
24
  });
21
- const labelClasses = computed(() => {
22
- const base = `${LABEL_BASE} ${LABEL_SIZES[size.value]}`;
23
- const res = required.value ? `${base} ${LABEL_REQUIRED}` : base;
24
- return res;
25
+ const inputClasses$1 = computed(() => allClasses.value.input);
26
+ const labelClasses = computed(() => allClasses.value.label);
27
+ const errorMsgClasses = computed(() => allClasses.value.errorMessage);
28
+ const selectClasses$1 = computed(() => {
29
+ const { input } = selectClasses({ size: size.value, required: required.value, error: !!errorMsg.value });
30
+ return input();
25
31
  });
26
- const selectClasses = computed(() => {
27
- const res = `${inputClasses.value.replace(` ${SPACING_RIGHT[size.value]}`, "")} ${SELECT_BASE} ${SELECT_ARROW} ${SELECT_SIZES[size.value]}`;
28
- return res;
32
+ const textareaClasses$1 = computed(() => {
33
+ const { input } = textareaClasses({ required: required.value, error: !!errorMsg.value });
34
+ return input();
29
35
  });
30
- const textareaClasses = computed(() => {
31
- const res = `${inputClasses.value} ${TEXTAREA_BASE}`;
32
- return res;
33
- });
34
- const errorMsgClasses = ref(ERROR_MSG);
35
36
  return {
36
- inputClasses,
37
+ inputClasses: inputClasses$1,
37
38
  labelClasses,
38
- selectClasses,
39
- textareaClasses,
39
+ selectClasses: selectClasses$1,
40
+ textareaClasses: textareaClasses$1,
40
41
  errorMsgClasses
41
42
  };
42
43
  }
@@ -1 +1,2 @@
1
- export type Size = 'sm' | 'md' | 'lg';
1
+ export declare const SIZES: readonly ["sm", "md", "lg"];
2
+ export type Size = (typeof SIZES)[number];