@pequity/squirrel 6.0.11 → 6.0.13

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 (78) 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-info-icon.js +37 -0
  4. package/dist/cjs/chunks/p-select.js +2 -2
  5. package/dist/cjs/index.js +25 -33
  6. package/dist/cjs/inputClasses.js +127 -0
  7. package/dist/cjs/inputClassesMixin.js +23 -19
  8. package/dist/cjs/p-btn.js +56 -57
  9. package/dist/cjs/p-icon.js +6 -1
  10. package/dist/cjs/p-info-icon.js +2 -33
  11. package/dist/cjs/p-input-number.js +2 -2
  12. package/dist/cjs/p-input-search.js +3 -3
  13. package/dist/cjs/p-table-header-cell.js +2 -2
  14. package/dist/cjs/useInputClasses.js +19 -18
  15. package/dist/es/chunks/index.js +2646 -0
  16. package/dist/es/chunks/p-btn.types.js +4 -0
  17. package/dist/es/chunks/p-info-icon.js +38 -0
  18. package/dist/es/chunks/p-select.js +2 -2
  19. package/dist/es/index.js +74 -82
  20. package/dist/es/inputClasses.js +127 -0
  21. package/dist/es/inputClassesMixin.js +23 -19
  22. package/dist/es/p-btn.js +56 -57
  23. package/dist/es/p-icon.js +6 -1
  24. package/dist/es/p-info-icon.js +2 -33
  25. package/dist/es/p-input-number.js +2 -2
  26. package/dist/es/p-input-search.js +3 -3
  27. package/dist/es/p-table-header-cell.js +2 -2
  28. package/dist/es/useInputClasses.js +23 -22
  29. package/dist/squirrel/components/p-alert/p-alert.vue.d.ts +1 -1
  30. package/dist/squirrel/components/p-btn/p-btn.types.d.ts +2 -1
  31. package/dist/squirrel/components/p-btn/p-btn.vue.d.ts +395 -17
  32. package/dist/squirrel/components/p-drawer/p-drawer.vue.d.ts +5 -5
  33. package/dist/squirrel/components/p-dropdown-select/p-dropdown-select.vue.d.ts +30 -22
  34. package/dist/squirrel/components/p-icon/p-icon.types.d.ts +5 -0
  35. package/dist/squirrel/components/p-input/p-input.vue.d.ts +11 -7
  36. package/dist/squirrel/components/p-input-number/p-input-number.vue.d.ts +11 -7
  37. package/dist/squirrel/components/p-input-percent/p-input-percent.vue.d.ts +3 -3
  38. package/dist/squirrel/components/p-input-search/p-input-search.vue.d.ts +16 -12
  39. package/dist/squirrel/components/p-select/p-select.vue.d.ts +5 -5
  40. package/dist/squirrel/components/p-select-list/p-select-list.vue.d.ts +30 -22
  41. package/dist/squirrel/components/p-textarea/p-textarea.vue.d.ts +11 -7
  42. package/dist/squirrel/components/p-toggle/p-toggle.vue.d.ts +11 -7
  43. package/dist/squirrel/composables/useInputClasses.d.ts +3 -3
  44. package/dist/squirrel/index.d.ts +1 -0
  45. package/dist/squirrel/utils/index.d.ts +2 -2
  46. package/dist/squirrel/utils/inputClasses.d.ts +938 -0
  47. package/dist/squirrel/utils/inputClassesMixin.d.ts +12 -8
  48. package/dist/squirrel.css +23 -23
  49. package/package.json +24 -21
  50. package/squirrel/components/p-btn/p-btn.spec.js +1 -1
  51. package/squirrel/components/p-btn/p-btn.types.ts +3 -1
  52. package/squirrel/components/p-btn/p-btn.vue +60 -74
  53. package/squirrel/components/p-dropdown/p-dropdown.vue +2 -2
  54. package/squirrel/components/p-file-upload/p-file-upload.spec.js +3 -8
  55. package/squirrel/components/p-icon/p-icon.types.ts +5 -0
  56. package/squirrel/components/p-info-icon/p-info-icon.spec.js +3 -2
  57. package/squirrel/components/p-info-icon/p-info-icon.vue +3 -7
  58. package/squirrel/components/p-inline-date-picker/p-inline-date-picker.spec.js +3 -10
  59. package/squirrel/components/p-input/p-input.spec.js +3 -8
  60. package/squirrel/components/p-input-number/p-input-number.spec.js +15 -18
  61. package/squirrel/components/p-input-percent/p-input-percent.spec.js +3 -8
  62. package/squirrel/components/p-input-percent/p-input-percent.vue +3 -3
  63. package/squirrel/components/p-input-search/p-input-search.vue +4 -4
  64. package/squirrel/components/p-select/p-select.spec.js +27 -33
  65. package/squirrel/components/p-select/p-select.vue +4 -4
  66. package/squirrel/components/p-table-header-cell/p-table-header-cell.spec.js +6 -4
  67. package/squirrel/components/p-textarea/p-textarea.spec.js +3 -8
  68. package/squirrel/composables/useInputClasses.spec.js +138 -77
  69. package/squirrel/composables/useInputClasses.ts +25 -39
  70. package/squirrel/index.ts +1 -0
  71. package/squirrel/utils/index.ts +3 -36
  72. package/squirrel/utils/inputClasses.ts +128 -0
  73. package/squirrel/utils/inputClassesMixin.spec.js +153 -64
  74. package/squirrel/utils/inputClassesMixin.ts +26 -43
  75. package/dist/cjs/inputClassesShared.js +0 -76
  76. package/dist/es/inputClassesShared.js +0 -76
  77. package/dist/squirrel/utils/inputClassesShared.d.ts +0 -45
  78. package/squirrel/utils/inputClassesShared.ts +0 -75
@@ -1,31 +1,14 @@
1
- import {
2
- ERROR_MSG,
3
- INPUT_BASE,
4
- INPUT_ERROR,
5
- INPUT_NORMAL,
6
- INPUT_SIZES,
7
- type InputSize,
8
- LABEL_BASE,
9
- LABEL_REQUIRED,
10
- LABEL_SIZES,
11
- SELECT_ARROW,
12
- SELECT_BASE,
13
- SELECT_SIZES,
14
- SPACING_LEFT,
15
- SPACING_PREFIX,
16
- SPACING_RIGHT,
17
- SPACING_SUFFIX,
18
- TEXTAREA_BASE,
19
- } from '@squirrel/utils/inputClassesShared';
1
+ import { type Size, SIZES } from '@squirrel/components/p-btn/p-btn.types';
2
+ import { inputClasses, selectClasses, textareaClasses } from '@squirrel/utils/inputClasses';
20
3
  import { defineComponent, type PropType } from 'vue';
21
4
 
22
5
  export default defineComponent({
23
6
  props: {
24
7
  size: {
25
- type: String as PropType<InputSize>,
8
+ type: String as PropType<Size>,
26
9
  default: 'md',
27
- validator(value: InputSize) {
28
- return Object.keys(INPUT_SIZES).includes(value);
10
+ validator(value: Size) {
11
+ return SIZES.includes(value);
29
12
  },
30
13
  },
31
14
  errorMsg: {
@@ -41,37 +24,37 @@ export default defineComponent({
41
24
  default: false,
42
25
  },
43
26
  },
44
- data() {
45
- return {
46
- errorMsgClasses: ERROR_MSG,
47
- };
48
- },
49
27
  computed: {
50
- inputClasses() {
51
- const base = `${INPUT_BASE} ${INPUT_SIZES[this.size]}`;
52
- const spacingLeft = this.$slots.prefix ? SPACING_PREFIX[this.size] : SPACING_LEFT[this.size];
53
- const spacingRight = this.$slots.suffix ? SPACING_SUFFIX[this.size] : SPACING_RIGHT[this.size];
54
- const res = `${base} ${spacingLeft} ${spacingRight} ${this.errorMsg ? INPUT_ERROR : INPUT_NORMAL}${this.rounded ? ' rounded-full' : ''}`;
28
+ allClasses() {
29
+ const { input, label, errorMessage } = 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
+ });
55
37
 
56
- return res;
38
+ return { input: input(), label: label(), errorMessage: errorMessage() };
39
+ },
40
+ inputClasses() {
41
+ return this.allClasses.input;
57
42
  },
58
43
  labelClasses() {
59
- const base = `${LABEL_BASE} ${LABEL_SIZES[this.size]}`;
60
- const res = this.required ? `${base} ${LABEL_REQUIRED}` : base;
61
-
62
- return res;
44
+ return this.allClasses.label;
45
+ },
46
+ errorMsgClasses() {
47
+ return this.allClasses.errorMessage;
63
48
  },
64
49
  selectClasses() {
65
- const res = `${this.inputClasses.replace(` ${SPACING_RIGHT[this.size]}`, '')} ${SELECT_BASE} ${SELECT_ARROW} ${
66
- SELECT_SIZES[this.size]
67
- }`;
50
+ const { input } = selectClasses({ size: this.size, required: this.required, error: !!this.errorMsg });
68
51
 
69
- return res;
52
+ return input();
70
53
  },
71
54
  textareaClasses() {
72
- const res = `${this.inputClasses} ${TEXTAREA_BASE}`;
55
+ const { input } = textareaClasses({ required: this.required, error: !!this.errorMsg });
73
56
 
74
- return res;
57
+ return input();
75
58
  },
76
59
  },
77
60
  });
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const LABEL_BASE = `block mb-1 font-medium`;
4
- const LABEL_SIZES = {
5
- sm: `text-xs`,
6
- md: `text-sm`,
7
- lg: `text-base`
8
- };
9
- const LABEL_REQUIRED = `after:content-['_*'] after:text-on-error`;
10
- const ERROR_MSG = `text-xs text-on-error mt-1`;
11
- const INPUT_BASE = [
12
- "text-night",
13
- "w-full",
14
- "bg-surface",
15
- "focus:outline-none",
16
- "border-0",
17
- "ring-1",
18
- "ring-inset",
19
- "focus:ring-2",
20
- "disabled:ring-p-gray-30",
21
- "disabled:hover:ring-p-gray-30",
22
- "disabled:bg-p-blue-10",
23
- "disabled:cursor-default",
24
- "placeholder:text-p-gray-40"
25
- ].join(" ");
26
- const INPUT_NORMAL = `ring-p-gray-30 hover:ring-primary focus:ring-primary`;
27
- const INPUT_ERROR = `ring-on-error hover:ring-on-error focus:ring-on-error`;
28
- const INPUT_SIZES = {
29
- sm: `h-8 text-sm rounded`,
30
- md: `h-10 text-base rounded`,
31
- lg: `h-12 text-lg rounded`
32
- };
33
- const TEXTAREA_BASE = `resize-y px-3 py-3 overflow-auto h-auto`;
34
- const SELECT_BASE = "truncate";
35
- const SELECT_ARROW = `squirrel-bg-chevron-down bg-no-repeat appearance-none`;
36
- const SELECT_SIZES = {
37
- sm: `bg-[right_0.675rem_center] pr-8`,
38
- md: `bg-[right_1rem_center] pr-10`,
39
- lg: `bg-[right_1.25rem_center] pr-12`
40
- };
41
- const SPACING_LEFT = {
42
- sm: `pl-3`,
43
- md: `pl-4`,
44
- lg: `pl-5`
45
- };
46
- const SPACING_RIGHT = {
47
- sm: `pr-3`,
48
- md: `pr-4`,
49
- lg: `pr-5`
50
- };
51
- const SPACING_PREFIX = {
52
- sm: `pl-6`,
53
- md: `pl-8`,
54
- lg: `pl-12`
55
- };
56
- const SPACING_SUFFIX = {
57
- sm: `pr-6`,
58
- md: `pr-8`,
59
- lg: `pr-12`
60
- };
61
- exports.ERROR_MSG = ERROR_MSG;
62
- exports.INPUT_BASE = INPUT_BASE;
63
- exports.INPUT_ERROR = INPUT_ERROR;
64
- exports.INPUT_NORMAL = INPUT_NORMAL;
65
- exports.INPUT_SIZES = INPUT_SIZES;
66
- exports.LABEL_BASE = LABEL_BASE;
67
- exports.LABEL_REQUIRED = LABEL_REQUIRED;
68
- exports.LABEL_SIZES = LABEL_SIZES;
69
- exports.SELECT_ARROW = SELECT_ARROW;
70
- exports.SELECT_BASE = SELECT_BASE;
71
- exports.SELECT_SIZES = SELECT_SIZES;
72
- exports.SPACING_LEFT = SPACING_LEFT;
73
- exports.SPACING_PREFIX = SPACING_PREFIX;
74
- exports.SPACING_RIGHT = SPACING_RIGHT;
75
- exports.SPACING_SUFFIX = SPACING_SUFFIX;
76
- exports.TEXTAREA_BASE = TEXTAREA_BASE;
@@ -1,76 +0,0 @@
1
- const LABEL_BASE = `block mb-1 font-medium`;
2
- const LABEL_SIZES = {
3
- sm: `text-xs`,
4
- md: `text-sm`,
5
- lg: `text-base`
6
- };
7
- const LABEL_REQUIRED = `after:content-['_*'] after:text-on-error`;
8
- const ERROR_MSG = `text-xs text-on-error mt-1`;
9
- const INPUT_BASE = [
10
- "text-night",
11
- "w-full",
12
- "bg-surface",
13
- "focus:outline-none",
14
- "border-0",
15
- "ring-1",
16
- "ring-inset",
17
- "focus:ring-2",
18
- "disabled:ring-p-gray-30",
19
- "disabled:hover:ring-p-gray-30",
20
- "disabled:bg-p-blue-10",
21
- "disabled:cursor-default",
22
- "placeholder:text-p-gray-40"
23
- ].join(" ");
24
- const INPUT_NORMAL = `ring-p-gray-30 hover:ring-primary focus:ring-primary`;
25
- const INPUT_ERROR = `ring-on-error hover:ring-on-error focus:ring-on-error`;
26
- const INPUT_SIZES = {
27
- sm: `h-8 text-sm rounded`,
28
- md: `h-10 text-base rounded`,
29
- lg: `h-12 text-lg rounded`
30
- };
31
- const TEXTAREA_BASE = `resize-y px-3 py-3 overflow-auto h-auto`;
32
- const SELECT_BASE = "truncate";
33
- const SELECT_ARROW = `squirrel-bg-chevron-down bg-no-repeat appearance-none`;
34
- const SELECT_SIZES = {
35
- sm: `bg-[right_0.675rem_center] pr-8`,
36
- md: `bg-[right_1rem_center] pr-10`,
37
- lg: `bg-[right_1.25rem_center] pr-12`
38
- };
39
- const SPACING_LEFT = {
40
- sm: `pl-3`,
41
- md: `pl-4`,
42
- lg: `pl-5`
43
- };
44
- const SPACING_RIGHT = {
45
- sm: `pr-3`,
46
- md: `pr-4`,
47
- lg: `pr-5`
48
- };
49
- const SPACING_PREFIX = {
50
- sm: `pl-6`,
51
- md: `pl-8`,
52
- lg: `pl-12`
53
- };
54
- const SPACING_SUFFIX = {
55
- sm: `pr-6`,
56
- md: `pr-8`,
57
- lg: `pr-12`
58
- };
59
- export {
60
- ERROR_MSG,
61
- INPUT_BASE,
62
- INPUT_ERROR,
63
- INPUT_NORMAL,
64
- INPUT_SIZES,
65
- LABEL_BASE,
66
- LABEL_REQUIRED,
67
- LABEL_SIZES,
68
- SELECT_ARROW,
69
- SELECT_BASE,
70
- SELECT_SIZES,
71
- SPACING_LEFT,
72
- SPACING_PREFIX,
73
- SPACING_RIGHT,
74
- SPACING_SUFFIX,
75
- TEXTAREA_BASE
76
- };
@@ -1,45 +0,0 @@
1
- export declare const LABEL_BASE = "block mb-1 font-medium";
2
- export declare const LABEL_SIZES: {
3
- sm: string;
4
- md: string;
5
- lg: string;
6
- };
7
- export declare const LABEL_REQUIRED = "after:content-['_*'] after:text-on-error";
8
- export declare const ERROR_MSG = "text-xs text-on-error mt-1";
9
- export declare const INPUT_BASE: string;
10
- export declare const INPUT_NORMAL = "ring-p-gray-30 hover:ring-primary focus:ring-primary";
11
- export declare const INPUT_ERROR = "ring-on-error hover:ring-on-error focus:ring-on-error";
12
- export declare const INPUT_SIZES: {
13
- readonly sm: "h-8 text-sm rounded";
14
- readonly md: "h-10 text-base rounded";
15
- readonly lg: "h-12 text-lg rounded";
16
- };
17
- export type InputSize = keyof typeof INPUT_SIZES;
18
- export declare const TEXTAREA_BASE = "resize-y px-3 py-3 overflow-auto h-auto";
19
- export declare const SELECT_BASE = "truncate";
20
- export declare const SELECT_ARROW = "squirrel-bg-chevron-down bg-no-repeat appearance-none";
21
- export declare const SELECT_SIZES: {
22
- sm: string;
23
- md: string;
24
- lg: string;
25
- };
26
- export declare const SPACING_LEFT: {
27
- sm: string;
28
- md: string;
29
- lg: string;
30
- };
31
- export declare const SPACING_RIGHT: {
32
- sm: string;
33
- md: string;
34
- lg: string;
35
- };
36
- export declare const SPACING_PREFIX: {
37
- sm: string;
38
- md: string;
39
- lg: string;
40
- };
41
- export declare const SPACING_SUFFIX: {
42
- sm: string;
43
- md: string;
44
- lg: string;
45
- };
@@ -1,75 +0,0 @@
1
- export const LABEL_BASE = `block mb-1 font-medium`;
2
-
3
- export const LABEL_SIZES = {
4
- sm: `text-xs`,
5
- md: `text-sm`,
6
- lg: `text-base`,
7
- };
8
-
9
- export const LABEL_REQUIRED = `after:content-['_*'] after:text-on-error`;
10
-
11
- export const ERROR_MSG = `text-xs text-on-error mt-1`;
12
-
13
- export const INPUT_BASE = [
14
- 'text-night',
15
- 'w-full',
16
- 'bg-surface',
17
- 'focus:outline-none',
18
- 'border-0',
19
- 'ring-1',
20
- 'ring-inset',
21
- 'focus:ring-2',
22
- 'disabled:ring-p-gray-30',
23
- 'disabled:hover:ring-p-gray-30',
24
- 'disabled:bg-p-blue-10',
25
- 'disabled:cursor-default',
26
- 'placeholder:text-p-gray-40',
27
- ].join(' ');
28
-
29
- export const INPUT_NORMAL = `ring-p-gray-30 hover:ring-primary focus:ring-primary`;
30
-
31
- export const INPUT_ERROR = `ring-on-error hover:ring-on-error focus:ring-on-error`;
32
-
33
- export const INPUT_SIZES = {
34
- sm: `h-8 text-sm rounded`,
35
- md: `h-10 text-base rounded`,
36
- lg: `h-12 text-lg rounded`,
37
- } as const;
38
-
39
- export type InputSize = keyof typeof INPUT_SIZES;
40
-
41
- export const TEXTAREA_BASE = `resize-y px-3 py-3 overflow-auto h-auto`;
42
-
43
- export const SELECT_BASE = 'truncate';
44
-
45
- export const SELECT_ARROW = `squirrel-bg-chevron-down bg-no-repeat appearance-none`;
46
-
47
- export const SELECT_SIZES = {
48
- sm: `bg-[right_0.675rem_center] pr-8`,
49
- md: `bg-[right_1rem_center] pr-10`,
50
- lg: `bg-[right_1.25rem_center] pr-12`,
51
- };
52
-
53
- export const SPACING_LEFT = {
54
- sm: `pl-3`,
55
- md: `pl-4`,
56
- lg: `pl-5`,
57
- };
58
-
59
- export const SPACING_RIGHT = {
60
- sm: `pr-3`,
61
- md: `pr-4`,
62
- lg: `pr-5`,
63
- };
64
-
65
- export const SPACING_PREFIX = {
66
- sm: `pl-6`,
67
- md: `pl-8`,
68
- lg: `pl-12`,
69
- };
70
-
71
- export const SPACING_SUFFIX = {
72
- sm: `pr-6`,
73
- md: `pr-8`,
74
- lg: `pr-12`,
75
- };