@pequity/squirrel 6.0.12 → 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.
- package/dist/cjs/chunks/index.js +2645 -0
- package/dist/cjs/chunks/p-btn.types.js +3 -0
- package/dist/cjs/chunks/p-select.js +2 -2
- package/dist/cjs/index.js +23 -31
- package/dist/cjs/inputClasses.js +127 -0
- package/dist/cjs/inputClassesMixin.js +23 -19
- package/dist/cjs/p-btn.js +56 -57
- package/dist/cjs/p-input-search.js +3 -3
- package/dist/cjs/useInputClasses.js +19 -18
- package/dist/es/chunks/index.js +2646 -0
- package/dist/es/chunks/p-btn.types.js +4 -0
- package/dist/es/chunks/p-select.js +2 -2
- package/dist/es/index.js +28 -36
- package/dist/es/inputClasses.js +127 -0
- package/dist/es/inputClassesMixin.js +23 -19
- package/dist/es/p-btn.js +56 -57
- package/dist/es/p-input-search.js +3 -3
- package/dist/es/useInputClasses.js +23 -22
- package/dist/squirrel/components/p-btn/p-btn.types.d.ts +2 -1
- package/dist/squirrel/components/p-btn/p-btn.vue.d.ts +395 -17
- package/dist/squirrel/components/p-dropdown-select/p-dropdown-select.vue.d.ts +30 -22
- package/dist/squirrel/components/p-input/p-input.vue.d.ts +11 -7
- package/dist/squirrel/components/p-input-number/p-input-number.vue.d.ts +11 -7
- package/dist/squirrel/components/p-input-percent/p-input-percent.vue.d.ts +3 -3
- package/dist/squirrel/components/p-input-search/p-input-search.vue.d.ts +16 -12
- package/dist/squirrel/components/p-select/p-select.vue.d.ts +5 -5
- package/dist/squirrel/components/p-select-list/p-select-list.vue.d.ts +30 -22
- package/dist/squirrel/components/p-textarea/p-textarea.vue.d.ts +11 -7
- package/dist/squirrel/components/p-toggle/p-toggle.vue.d.ts +11 -7
- package/dist/squirrel/composables/useInputClasses.d.ts +3 -3
- package/dist/squirrel/index.d.ts +1 -0
- package/dist/squirrel/utils/index.d.ts +2 -2
- package/dist/squirrel/utils/inputClasses.d.ts +938 -0
- package/dist/squirrel/utils/inputClassesMixin.d.ts +12 -8
- package/dist/squirrel.css +13 -13
- package/package.json +10 -7
- package/squirrel/components/p-btn/p-btn.spec.js +1 -1
- package/squirrel/components/p-btn/p-btn.types.ts +3 -1
- package/squirrel/components/p-btn/p-btn.vue +60 -74
- package/squirrel/components/p-file-upload/p-file-upload.spec.js +3 -8
- package/squirrel/components/p-inline-date-picker/p-inline-date-picker.spec.js +3 -10
- package/squirrel/components/p-input/p-input.spec.js +3 -8
- package/squirrel/components/p-input-number/p-input-number.spec.js +15 -18
- package/squirrel/components/p-input-percent/p-input-percent.spec.js +3 -8
- package/squirrel/components/p-input-percent/p-input-percent.vue +3 -3
- package/squirrel/components/p-input-search/p-input-search.vue +4 -4
- package/squirrel/components/p-select/p-select.spec.js +27 -33
- package/squirrel/components/p-select/p-select.vue +4 -4
- package/squirrel/components/p-textarea/p-textarea.spec.js +3 -8
- package/squirrel/composables/useInputClasses.spec.js +138 -77
- package/squirrel/composables/useInputClasses.ts +25 -39
- package/squirrel/index.ts +1 -0
- package/squirrel/utils/index.ts +3 -36
- package/squirrel/utils/inputClasses.ts +128 -0
- package/squirrel/utils/inputClassesMixin.spec.js +153 -64
- package/squirrel/utils/inputClassesMixin.ts +26 -43
- package/dist/cjs/inputClassesShared.js +0 -76
- package/dist/es/inputClassesShared.js +0 -76
- package/dist/squirrel/utils/inputClassesShared.d.ts +0 -45
- package/squirrel/utils/inputClassesShared.ts +0 -75
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent, useAttrs, computed, createElementBlock, openBlock, normalizeStyle, normalizeClass, unref, renderSlot, createElementVNode, withDirectives, createCommentVNode, toDisplayString, mergeProps, Fragment, renderList, vShow } from "vue";
|
|
2
|
+
import { S as SIZES } from "./p-btn.types.js";
|
|
2
3
|
import { useInputClasses } from "../useInputClasses.js";
|
|
3
|
-
import { INPUT_SIZES } from "../inputClassesShared.js";
|
|
4
4
|
const _hoisted_1 = ["data-has-error"];
|
|
5
5
|
const _hoisted_2 = ["value"];
|
|
6
6
|
const _hoisted_3 = ["value"];
|
|
@@ -36,7 +36,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
36
36
|
type: String,
|
|
37
37
|
default: "md",
|
|
38
38
|
validator(value) {
|
|
39
|
-
return
|
|
39
|
+
return SIZES.includes(value);
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
itemText: {
|
package/dist/es/index.js
CHANGED
|
@@ -55,16 +55,17 @@ import { _ as _15 } from "./chunks/p-tabs.js";
|
|
|
55
55
|
import { default as default19 } from "./p-textarea.js";
|
|
56
56
|
import { default as default20 } from "./p-toggle.js";
|
|
57
57
|
import { squirrelTailwindConfig } from "./config.js";
|
|
58
|
+
import { S } from "./chunks/p-btn.types.js";
|
|
58
59
|
import { CURRENCY_INPUT_DEFAULTS } from "./currency.js";
|
|
59
60
|
import { getNextActiveElement, isElement, isVisible } from "./dom.js";
|
|
60
61
|
import { default as default21 } from "./inputClassesMixin.js";
|
|
61
|
-
import { ERROR_MSG, INPUT_BASE, INPUT_ERROR, INPUT_NORMAL, INPUT_SIZES, LABEL_BASE, LABEL_REQUIRED, LABEL_SIZES, SELECT_ARROW, SELECT_BASE, SELECT_SIZES, SPACING_LEFT, SPACING_PREFIX, SPACING_RIGHT, SPACING_SUFFIX, TEXTAREA_BASE } from "./inputClassesShared.js";
|
|
62
62
|
import { setupListKeyboardNavigation } from "./listKeyboardNavigation.js";
|
|
63
63
|
import { toNumberOrNull } from "./number.js";
|
|
64
64
|
import { isObject } from "./object.js";
|
|
65
65
|
import { createPagingRange } from "./pagination.js";
|
|
66
66
|
import { sanitizeUrl } from "./sanitization.js";
|
|
67
67
|
import { getColor, getColorDeep, getScreen } from "./tailwind.js";
|
|
68
|
+
import { M, N, f, i, c, x } from "./chunks/index.js";
|
|
68
69
|
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
70
|
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";
|
|
70
71
|
const _hoisted_1$3 = ["data-has-error"];
|
|
@@ -165,8 +166,8 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
165
166
|
});
|
|
166
167
|
const validateFiles = (filesToUpload) => {
|
|
167
168
|
const res = [];
|
|
168
|
-
for (let
|
|
169
|
-
const file = filesToUpload[
|
|
169
|
+
for (let i2 = 0; i2 < filesToUpload.length; i2++) {
|
|
170
|
+
const file = filesToUpload[i2];
|
|
170
171
|
const fileName = file.name || file.url;
|
|
171
172
|
if (res.length + files.value.length >= props.maxNumberOfFiles) {
|
|
172
173
|
toast.error(`You can only upload a maximum of ${props.maxNumberOfFiles} ${fileWord.value}.`);
|
|
@@ -198,11 +199,11 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
198
199
|
};
|
|
199
200
|
const uploadFile = (e) => {
|
|
200
201
|
var _a, _b;
|
|
201
|
-
const
|
|
202
|
-
if (!
|
|
202
|
+
const f2 = ((_a = e.target) == null ? void 0 : _a.files) || ((_b = e.dataTransfer) == null ? void 0 : _b.files);
|
|
203
|
+
if (!f2) {
|
|
203
204
|
return;
|
|
204
205
|
}
|
|
205
|
-
const validatedFiles = props.fileTypes ? validateFiles(Array.from(
|
|
206
|
+
const validatedFiles = props.fileTypes ? validateFiles(Array.from(f2)) : f2;
|
|
206
207
|
files.value = props.multiple ? [...files.value, ...validatedFiles] : validatedFiles;
|
|
207
208
|
emit("file-added", validatedFiles);
|
|
208
209
|
};
|
|
@@ -723,17 +724,17 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
723
724
|
const emitScroll = (e) => {
|
|
724
725
|
emit("scroll", e);
|
|
725
726
|
};
|
|
726
|
-
const thDivClasses = (
|
|
727
|
+
const thDivClasses = (i2) => {
|
|
727
728
|
const res = ["relative", "py-2"];
|
|
728
729
|
res.push("border-b border-p-gray-30");
|
|
729
|
-
if (
|
|
730
|
+
if (i2 === 0 && props.isFirstColFixed || i2 === props.cols.length - 1 && props.isLastColFixed) {
|
|
730
731
|
res.push("th-shadow px-4");
|
|
731
732
|
} else {
|
|
732
733
|
!props.colsResizable ? res.push("px-2") : res.push("pl-2 pr-4");
|
|
733
734
|
}
|
|
734
735
|
return res;
|
|
735
736
|
};
|
|
736
|
-
const thSubheaderClasses = (
|
|
737
|
+
const thSubheaderClasses = (i2) => {
|
|
737
738
|
const res = [
|
|
738
739
|
"flex",
|
|
739
740
|
"h-6",
|
|
@@ -746,7 +747,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
746
747
|
"font-medium",
|
|
747
748
|
"text-p-gray-40"
|
|
748
749
|
];
|
|
749
|
-
if (
|
|
750
|
+
if (i2 === 0 && props.isFirstColFixed || i2 === props.cols.length - 1 && props.isLastColFixed) {
|
|
750
751
|
res.push("th-shadow");
|
|
751
752
|
}
|
|
752
753
|
return res;
|
|
@@ -805,10 +806,10 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
805
806
|
}, toHandlers(_ctx.colsResizable ? { mousemove: unref(colResize) } : {}, true)), [
|
|
806
807
|
createElementVNode("thead", null, [
|
|
807
808
|
createElementVNode("tr", null, [
|
|
808
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(props.cols, (col,
|
|
809
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(props.cols, (col, i2) => {
|
|
809
810
|
return openBlock(), createElementBlock("th", mergeProps({
|
|
810
811
|
ref_for: true,
|
|
811
|
-
ref: (el) => updateThsRefs(el,
|
|
812
|
+
ref: (el) => updateThsRefs(el, i2),
|
|
812
813
|
key: col.id,
|
|
813
814
|
"data-col-id": col.id
|
|
814
815
|
}, col.thAttrs, {
|
|
@@ -816,7 +817,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
816
817
|
class: "bg-surface"
|
|
817
818
|
}), [
|
|
818
819
|
createElementVNode("div", {
|
|
819
|
-
class: normalizeClass(thDivClasses(
|
|
820
|
+
class: normalizeClass(thDivClasses(i2)),
|
|
820
821
|
style: normalizeStyle(bgColorStyle(col))
|
|
821
822
|
}, [
|
|
822
823
|
createElementVNode("div", _hoisted_2$1, [
|
|
@@ -826,24 +827,24 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
826
827
|
"filter-active": col.filterActive,
|
|
827
828
|
"show-filter-icon": col.filterable || col.sortable,
|
|
828
829
|
"tooltip-text": col.tooltip,
|
|
829
|
-
class: [{ "pl-2":
|
|
830
|
+
class: [{ "pl-2": i2 === 1 && _ctx.isFirstColFixed, "pr-2": i2 === _ctx.cols.length && _ctx.isLastColFixed }, "grow"],
|
|
830
831
|
"text-color": headerCellTextColor(col),
|
|
831
832
|
ref_for: true
|
|
832
833
|
}, col.headerCellAttrs, {
|
|
833
834
|
onClickFilterIcon: ($event) => _ctx.$emit("click-filter-icon", $event, col)
|
|
834
835
|
}), null, 16, ["text", "filter-active", "show-filter-icon", "tooltip-text", "class", "text-color", "onClickFilterIcon"])
|
|
835
836
|
]),
|
|
836
|
-
_ctx.colsResizable &&
|
|
837
|
+
_ctx.colsResizable && i2 !== 0 && !(i2 === _ctx.cols.length - 1 && _ctx.isLastColFixed) ? (openBlock(), createElementBlock("div", {
|
|
837
838
|
key: 0,
|
|
838
|
-
class: normalizeClass(["absolute bottom-2 right-0 z-110 h-5 w-2 cursor-col-resize after:absolute after:bottom-0 after:z-110 after:block after:h-full after:w-2 after:cursor-col-resize after:border-r-2 after:border-dashed after:border-p-gray-30",
|
|
839
|
+
class: normalizeClass(["absolute bottom-2 right-0 z-110 h-5 w-2 cursor-col-resize after:absolute after:bottom-0 after:z-110 after:block after:h-full after:w-2 after:cursor-col-resize after:border-r-2 after:border-dashed after:border-p-gray-30", i2 === _ctx.cols.length - 1 ? "after:right-0.5" : "after:right-0"]),
|
|
839
840
|
"data-resize-handle": "",
|
|
840
|
-
onMousedown: ($event) => unref(colResizeStart)($event,
|
|
841
|
-
onDblclick: ($event) => unref(colResizeFitToData)(
|
|
841
|
+
onMousedown: ($event) => unref(colResizeStart)($event, i2),
|
|
842
|
+
onDblclick: ($event) => unref(colResizeFitToData)(i2)
|
|
842
843
|
}, null, 42, _hoisted_3$1)) : createCommentVNode("", true)
|
|
843
844
|
], 6),
|
|
844
845
|
_ctx.subheader ? (openBlock(), createElementBlock("div", {
|
|
845
846
|
key: 0,
|
|
846
|
-
class: normalizeClass(thSubheaderClasses(
|
|
847
|
+
class: normalizeClass(thSubheaderClasses(i2))
|
|
847
848
|
}, [
|
|
848
849
|
renderSlot(_ctx.$slots, `subheader-cell-${unref(kebabCase)(col.name)}`, {}, void 0, true)
|
|
849
850
|
], 2)) : createCommentVNode("", true)
|
|
@@ -955,14 +956,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
955
956
|
const pTableSort = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
956
957
|
export {
|
|
957
958
|
CURRENCY_INPUT_DEFAULTS,
|
|
958
|
-
ERROR_MSG,
|
|
959
|
-
INPUT_BASE,
|
|
960
|
-
INPUT_ERROR,
|
|
961
|
-
INPUT_NORMAL,
|
|
962
|
-
INPUT_SIZES,
|
|
963
|
-
LABEL_BASE,
|
|
964
|
-
LABEL_REQUIRED,
|
|
965
|
-
LABEL_SIZES,
|
|
966
959
|
MIN_WIDTH_COL_RESIZE,
|
|
967
960
|
_ as PActionBar,
|
|
968
961
|
default2 as PAlert,
|
|
@@ -1006,17 +999,14 @@ export {
|
|
|
1006
999
|
default19 as PTextarea,
|
|
1007
1000
|
default20 as PToggle,
|
|
1008
1001
|
P_ICON_ALIASES,
|
|
1009
|
-
|
|
1010
|
-
SELECT_BASE,
|
|
1011
|
-
SELECT_SIZES,
|
|
1002
|
+
S as SIZES,
|
|
1012
1003
|
SORTING_TYPES,
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
SPACING_RIGHT,
|
|
1016
|
-
SPACING_SUFFIX,
|
|
1017
|
-
TEXTAREA_BASE,
|
|
1004
|
+
M as cn,
|
|
1005
|
+
N as cnBase,
|
|
1018
1006
|
colsInjectionKey,
|
|
1019
1007
|
createPagingRange,
|
|
1008
|
+
f as createTV,
|
|
1009
|
+
i as defaultConfig,
|
|
1020
1010
|
getColor,
|
|
1021
1011
|
getColorDeep,
|
|
1022
1012
|
getNextActiveElement,
|
|
@@ -1034,10 +1024,12 @@ export {
|
|
|
1034
1024
|
squirrelTailwindConfig,
|
|
1035
1025
|
toNumberOrNull,
|
|
1036
1026
|
toString,
|
|
1027
|
+
c as tv,
|
|
1037
1028
|
useInputClasses,
|
|
1038
1029
|
usePLoading,
|
|
1039
1030
|
usePModal,
|
|
1040
1031
|
usePTableColResize,
|
|
1041
1032
|
usePTableRowVirtualizer,
|
|
1042
|
-
useSelectList
|
|
1033
|
+
useSelectList,
|
|
1034
|
+
x as voidEmpty
|
|
1043
1035
|
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { c as ce } from "./chunks/index.js";
|
|
2
|
+
const inputClasses = ce({
|
|
3
|
+
slots: {
|
|
4
|
+
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",
|
|
5
|
+
label: "mb-1 block font-medium",
|
|
6
|
+
errorMessage: "mt-1 text-xs text-on-error"
|
|
7
|
+
},
|
|
8
|
+
variants: {
|
|
9
|
+
size: {
|
|
10
|
+
sm: {
|
|
11
|
+
input: "h-8 pl-3 pr-3 text-sm",
|
|
12
|
+
label: "text-xs"
|
|
13
|
+
},
|
|
14
|
+
md: {
|
|
15
|
+
input: "h-10 pl-4 pr-4 text-base",
|
|
16
|
+
label: "text-sm"
|
|
17
|
+
},
|
|
18
|
+
lg: {
|
|
19
|
+
input: "h-12 pl-5 pr-5 text-lg",
|
|
20
|
+
label: "text-base"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
prefix: {
|
|
24
|
+
true: "pl-8"
|
|
25
|
+
},
|
|
26
|
+
suffix: {
|
|
27
|
+
true: "pr-6"
|
|
28
|
+
},
|
|
29
|
+
required: {
|
|
30
|
+
true: {
|
|
31
|
+
label: `after:text-on-error after:content-["_*"]`
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
error: {
|
|
35
|
+
true: {
|
|
36
|
+
input: "ring-on-error hover:ring-on-error focus:ring-on-error"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
rounded: {
|
|
40
|
+
true: "rounded-full"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
compoundVariants: [
|
|
44
|
+
{
|
|
45
|
+
size: "sm",
|
|
46
|
+
prefix: true,
|
|
47
|
+
class: {
|
|
48
|
+
input: "pl-6"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
size: "md",
|
|
53
|
+
prefix: true,
|
|
54
|
+
class: {
|
|
55
|
+
input: "pl-8"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
size: "lg",
|
|
60
|
+
prefix: true,
|
|
61
|
+
class: {
|
|
62
|
+
input: "pl-12"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
size: "sm",
|
|
67
|
+
suffix: true,
|
|
68
|
+
class: {
|
|
69
|
+
input: "pr-6"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
size: "md",
|
|
74
|
+
suffix: true,
|
|
75
|
+
class: {
|
|
76
|
+
input: "pr-8"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
size: "lg",
|
|
81
|
+
suffix: true,
|
|
82
|
+
class: {
|
|
83
|
+
input: "pr-12"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
defaultVariants: {
|
|
88
|
+
size: "md"
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const textareaClasses = ce({
|
|
92
|
+
extend: inputClasses,
|
|
93
|
+
slots: {
|
|
94
|
+
input: "resize-y overflow-auto px-3 py-3"
|
|
95
|
+
},
|
|
96
|
+
variants: {
|
|
97
|
+
size: {
|
|
98
|
+
md: {
|
|
99
|
+
input: "h-auto"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
const selectClasses = ce({
|
|
105
|
+
extend: inputClasses,
|
|
106
|
+
slots: {
|
|
107
|
+
input: "squirrel-bg-chevron-down appearance-none truncate bg-no-repeat"
|
|
108
|
+
},
|
|
109
|
+
variants: {
|
|
110
|
+
size: {
|
|
111
|
+
sm: {
|
|
112
|
+
input: "bg-[right_0.675rem_center] pr-8"
|
|
113
|
+
},
|
|
114
|
+
md: {
|
|
115
|
+
input: "bg-[right_1rem_center] pr-10"
|
|
116
|
+
},
|
|
117
|
+
lg: {
|
|
118
|
+
input: "bg-[right_1.25rem_center] pr-12"
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
export {
|
|
124
|
+
inputClasses,
|
|
125
|
+
selectClasses,
|
|
126
|
+
textareaClasses
|
|
127
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as SIZES } from "./chunks/p-btn.types.js";
|
|
2
|
+
import { textareaClasses, selectClasses, inputClasses } from "./inputClasses.js";
|
|
2
3
|
import { defineComponent } from "vue";
|
|
3
4
|
const inputClassesMixin = defineComponent({
|
|
4
5
|
props: {
|
|
@@ -6,7 +7,7 @@ const inputClassesMixin = defineComponent({
|
|
|
6
7
|
type: String,
|
|
7
8
|
default: "md",
|
|
8
9
|
validator(value) {
|
|
9
|
-
return
|
|
10
|
+
return SIZES.includes(value);
|
|
10
11
|
}
|
|
11
12
|
},
|
|
12
13
|
errorMsg: {
|
|
@@ -22,31 +23,34 @@ const inputClassesMixin = defineComponent({
|
|
|
22
23
|
default: false
|
|
23
24
|
}
|
|
24
25
|
},
|
|
25
|
-
data() {
|
|
26
|
-
return {
|
|
27
|
-
errorMsgClasses: ERROR_MSG
|
|
28
|
-
};
|
|
29
|
-
},
|
|
30
26
|
computed: {
|
|
27
|
+
allClasses() {
|
|
28
|
+
const { input, label, errorMessage } = inputClasses({
|
|
29
|
+
size: this.size,
|
|
30
|
+
prefix: !!this.$slots.prefix,
|
|
31
|
+
suffix: !!this.$slots.suffix,
|
|
32
|
+
required: this.required,
|
|
33
|
+
error: !!this.errorMsg,
|
|
34
|
+
rounded: this.rounded
|
|
35
|
+
});
|
|
36
|
+
return { input: input(), label: label(), errorMessage: errorMessage() };
|
|
37
|
+
},
|
|
31
38
|
inputClasses() {
|
|
32
|
-
|
|
33
|
-
const spacingLeft = this.$slots.prefix ? SPACING_PREFIX[this.size] : SPACING_LEFT[this.size];
|
|
34
|
-
const spacingRight = this.$slots.suffix ? SPACING_SUFFIX[this.size] : SPACING_RIGHT[this.size];
|
|
35
|
-
const res = `${base} ${spacingLeft} ${spacingRight} ${this.errorMsg ? INPUT_ERROR : INPUT_NORMAL}${this.rounded ? " rounded-full" : ""}`;
|
|
36
|
-
return res;
|
|
39
|
+
return this.allClasses.input;
|
|
37
40
|
},
|
|
38
41
|
labelClasses() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
return this.allClasses.label;
|
|
43
|
+
},
|
|
44
|
+
errorMsgClasses() {
|
|
45
|
+
return this.allClasses.errorMessage;
|
|
42
46
|
},
|
|
43
47
|
selectClasses() {
|
|
44
|
-
const
|
|
45
|
-
return
|
|
48
|
+
const { input } = selectClasses({ size: this.size, required: this.required, error: !!this.errorMsg });
|
|
49
|
+
return input();
|
|
46
50
|
},
|
|
47
51
|
textareaClasses() {
|
|
48
|
-
const
|
|
49
|
-
return
|
|
52
|
+
const { input } = textareaClasses({ required: this.required, error: !!this.errorMsg });
|
|
53
|
+
return input();
|
|
50
54
|
}
|
|
51
55
|
}
|
|
52
56
|
});
|
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
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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:
|
|
164
|
-
}, null, 8, ["
|
|
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
|
|
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-
|
|
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 {
|
|
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
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
27
|
-
const
|
|
28
|
-
return
|
|
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
|
|
1
|
+
export declare const SIZES: readonly ["sm", "md", "lg"];
|
|
2
|
+
export type Size = (typeof SIZES)[number];
|