@indielayer/ui 1.9.3 → 1.10.1

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 (101) hide show
  1. package/docs/components/menu/DocsMenu.vue +1 -0
  2. package/docs/pages/component/form/usage.vue +2 -0
  3. package/docs/pages/component/menu/usage.vue +2 -0
  4. package/docs/pages/component/select/index.vue +7 -0
  5. package/docs/pages/component/select/multiple.vue +42 -0
  6. package/docs/pages/component/select/usage.vue +8 -12
  7. package/docs/pages/component/table/virtual.vue +19 -6
  8. package/docs/pages/component/toggle/index.vue +1 -1
  9. package/docs/pages/component/tooltip/index.vue +1 -1
  10. package/docs/pages/component/upload/index.vue +29 -0
  11. package/docs/pages/component/upload/usage.vue +115 -0
  12. package/docs/search/components.json +1 -1
  13. package/lib/common/icons.d.ts +2 -0
  14. package/lib/common/icons.js +17 -15
  15. package/lib/components/button/theme/Button.base.theme.js +30 -27
  16. package/lib/components/checkbox/Checkbox.vue2.js +9 -9
  17. package/lib/components/datepicker/Datepicker.vue.d.ts +4 -4
  18. package/lib/components/datepicker/Datepicker.vue.js +1 -1
  19. package/lib/components/drawer/Drawer.vue.js +1 -17
  20. package/lib/components/form/Form.vue.d.ts +4 -4
  21. package/lib/components/form/Form.vue.js +34 -34
  22. package/lib/components/formGroup/FormGroup.vue.d.ts +1 -1
  23. package/lib/components/formGroup/FormGroup.vue.js +39 -37
  24. package/lib/components/index.d.ts +1 -0
  25. package/lib/components/index.js +68 -66
  26. package/lib/components/label/theme/Label.base.theme.js +7 -7
  27. package/lib/components/menu/Menu.vue.d.ts +2 -0
  28. package/lib/components/menu/MenuItem.vue.d.ts +15 -3
  29. package/lib/components/menu/MenuItem.vue.js +1 -1
  30. package/lib/components/menu/MenuItem.vue2.js +43 -37
  31. package/lib/components/modal/Modal.vue.d.ts +4 -4
  32. package/lib/components/modal/Modal.vue.js +38 -34
  33. package/lib/components/notifications/Notifications.vue.d.ts +15 -0
  34. package/lib/components/notifications/Notifications.vue.js +149 -127
  35. package/lib/components/progress/Progress.vue.d.ts +4 -4
  36. package/lib/components/progress/Progress.vue.js +7 -7
  37. package/lib/components/scroll/Scroll.vue2.js +1 -1
  38. package/lib/components/select/Select.vue.d.ts +43 -1
  39. package/lib/components/select/Select.vue.js +358 -258
  40. package/lib/components/select/theme/Select.base.theme.js +1 -0
  41. package/lib/components/tab/Tab.vue.js +1 -1
  42. package/lib/components/tab/TabGroup.vue.js +2 -2
  43. package/lib/components/table/TableCell.vue.d.ts +1 -1
  44. package/lib/components/table/theme/TableHead.base.theme.js +1 -1
  45. package/lib/components/table/theme/TableHeader.base.theme.js +1 -1
  46. package/lib/components/tag/Tag.vue.js +23 -21
  47. package/lib/components/textarea/Textarea.vue.js +1 -1
  48. package/lib/components/upload/Upload.vue.d.ts +195 -0
  49. package/lib/components/upload/Upload.vue.js +264 -0
  50. package/lib/components/upload/Upload.vue2.js +4 -0
  51. package/lib/components/upload/__tests__/Upload.spec.d.ts +1 -0
  52. package/lib/components/upload/index.d.ts +2 -0
  53. package/lib/components/upload/theme/Upload.base.theme.d.ts +3 -0
  54. package/lib/components/upload/theme/Upload.base.theme.js +8 -0
  55. package/lib/components/upload/theme/Upload.carbon.theme.d.ts +3 -0
  56. package/lib/components/upload/theme/Upload.carbon.theme.js +5 -0
  57. package/lib/composables/useVirtualList.js +56 -53
  58. package/lib/index.js +43 -41
  59. package/lib/index.umd.js +4 -4
  60. package/lib/node_modules/.pnpm/@vueuse_core@11.1.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/core/index.js +501 -0
  61. package/lib/node_modules/.pnpm/@vueuse_shared@11.1.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/shared/index.js +96 -0
  62. package/lib/theme.d.ts +2 -1
  63. package/lib/themes/base/components.d.ts +1 -0
  64. package/lib/themes/base/components.js +23 -21
  65. package/lib/themes/carbon/components.d.ts +1 -0
  66. package/lib/themes/carbon/components.js +23 -21
  67. package/lib/version.d.ts +1 -1
  68. package/lib/version.js +1 -1
  69. package/package.json +3 -3
  70. package/src/common/icons.ts +2 -0
  71. package/src/components/button/theme/Button.base.theme.ts +6 -3
  72. package/src/components/checkbox/Checkbox.vue +5 -5
  73. package/src/components/drawer/Drawer.vue +0 -16
  74. package/src/components/form/Form.vue +10 -4
  75. package/src/components/formGroup/FormGroup.vue +2 -0
  76. package/src/components/index.ts +1 -0
  77. package/src/components/label/theme/Label.base.theme.ts +7 -5
  78. package/src/components/menu/Menu.vue +2 -0
  79. package/src/components/menu/MenuItem.vue +8 -6
  80. package/src/components/modal/Modal.vue +6 -1
  81. package/src/components/notifications/Notifications.vue +34 -4
  82. package/src/components/progress/Progress.vue +2 -2
  83. package/src/components/select/Select.vue +166 -68
  84. package/src/components/select/theme/Select.base.theme.ts +2 -0
  85. package/src/components/table/theme/TableHead.base.theme.ts +1 -1
  86. package/src/components/table/theme/TableHeader.base.theme.ts +1 -1
  87. package/src/components/tag/Tag.vue +12 -10
  88. package/src/components/upload/Upload.vue +365 -0
  89. package/src/components/upload/__tests__/Upload.spec.ts +11 -0
  90. package/src/components/upload/index.ts +2 -0
  91. package/src/components/upload/theme/Upload.base.theme.ts +9 -0
  92. package/src/components/upload/theme/Upload.carbon.theme.ts +7 -0
  93. package/src/composables/useInputtable.ts +1 -1
  94. package/src/composables/useVirtualList.ts +8 -5
  95. package/src/theme.ts +2 -0
  96. package/src/themes/base/components.ts +1 -0
  97. package/src/themes/carbon/components.ts +1 -0
  98. package/src/version.ts +1 -1
  99. package/volar.d.ts +1 -0
  100. package/lib/node_modules/.pnpm/@vueuse_core@10.2.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/core/index.js +0 -412
  101. package/lib/node_modules/.pnpm/@vueuse_shared@10.2.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/shared/index.js +0 -90
@@ -5,6 +5,7 @@ const t = {
5
5
  const r = ["w-full border border-secondary-300 dark:border-secondary-700 pr-8 outline-transparent outline outline-2 outline-offset-[-1px] transition-all duration-150 ease-in-out rounded-md shadow-sm"];
6
6
  return !s.errorInternal && !e.disabled && r.push("hover:border-secondary-400 dark:hover:border-secondary-500"), e.size === "xs" ? r.push("px-2 py-1 text-xs") : e.size === "sm" ? r.push("px-2 py-1.5 text-sm") : e.size === "lg" ? r.push("px-4 py-3 text-lg") : e.size === "xl" ? r.push("px-5 py-4 text-xl") : r.push("px-3 py-2"), e.disabled ? r.push("bg-secondary-100 dark:bg-secondary-700 text-secondary-400 dark:text-secondary-600 cursor-not-allowed") : r.push("bg-white dark:bg-secondary-800 text-secondary-700 dark:text-secondary-200"), s.errorInternal ? r.push("border-error-500 dark:border-error-400 group-focus:outline-error-500") : e.disabled || r.push("group-focus:outline-[color:var(--x-select-border)]"), r;
7
7
  },
8
+ truncateCounter: "absolute right-0 cursor-pointer hover:bg-secondary-200 bg-secondary-100 text-secondary-800 rounded px-1 py-0.5 text-xs",
8
9
  content: "p-1",
9
10
  search: "p-1 mb-0.5",
10
11
  contentBody: "overflow-y-auto max-h-64 min-w-[280px]",
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as R, computed as s, ref as d, inject as j, reactive as D, onMounted as E, openBlock as c, createBlock as m, resolveDynamicComponent as L, normalizeStyle as V, unref as o, normalizeClass as v, withCtx as M, renderSlot as g, createElementVNode as z, createCommentVNode as p, toDisplayString as O, Teleport as P, createElementBlock as X } from "vue";
2
- import { useMutationObserver as F } from "../../node_modules/.pnpm/@vueuse_core@10.2.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/core/index.js";
2
+ import { useMutationObserver as F } from "../../node_modules/.pnpm/@vueuse_core@11.1.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/core/index.js";
3
3
  import { injectTabGroupKey as G } from "../../composables/keys.js";
4
4
  import { useCommon as T } from "../../composables/useCommon.js";
5
5
  import { useTheme as I } from "../../composables/useTheme.js";
@@ -1,11 +1,11 @@
1
1
  import { defineComponent as B, ref as r, watchEffect as z, reactive as E, computed as o, provide as V, watch as G, onMounted as N, openBlock as $, createElementBlock as q, createElementVNode as f, normalizeClass as v, unref as n, normalizeStyle as F, createVNode as L, withCtx as M, renderSlot as O, withDirectives as W, vShow as X, nextTick as j } from "vue";
2
- import { useMutationObserver as D, useResizeObserver as K } from "../../node_modules/.pnpm/@vueuse_core@10.2.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/core/index.js";
2
+ import { useMutationObserver as D, useResizeObserver as K } from "../../node_modules/.pnpm/@vueuse_core@11.1.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/core/index.js";
3
3
  import { injectTabGroupKey as P } from "../../composables/keys.js";
4
4
  import { useCommon as b } from "../../composables/useCommon.js";
5
5
  import { useColors as A } from "../../composables/useColors.js";
6
6
  import { useTheme as H } from "../../composables/useTheme.js";
7
7
  import I from "../scroll/Scroll.vue.js";
8
- import { useThrottleFn as J } from "../../node_modules/.pnpm/@vueuse_shared@10.2.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/shared/index.js";
8
+ import { useThrottleFn as J } from "../../node_modules/.pnpm/@vueuse_shared@11.1.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/shared/index.js";
9
9
  const Q = {
10
10
  ...b.validators(),
11
11
  variant: ["line", "block"],
@@ -51,8 +51,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<im
51
51
  validator: (value: string) => boolean;
52
52
  };
53
53
  }>> & Readonly<{}>, {
54
- dense: boolean;
55
54
  truncate: boolean;
55
+ dense: boolean;
56
56
  verticalAlign: "top" | "bottom" | "baseline" | "middle" | "text-bottom" | "text-top" | null;
57
57
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, {
58
58
  default?(_: {}): any;
@@ -4,7 +4,7 @@ const s = {
4
4
  const e = ["align-bottom bg-secondary-50 dark:bg-secondary-700"];
5
5
  return t.stickyHeader && e.push("sticky top-0 z-10"), e;
6
6
  },
7
- row: "text-sm text-secondary-600 dark:text-secondary-200 border-b"
7
+ row: "text-sm text-secondary-700 dark:text-secondary-200 border-b"
8
8
  }
9
9
  }, a = s;
10
10
  export {
@@ -1,7 +1,7 @@
1
1
  const s = {
2
2
  classes: {
3
3
  th: ({ props: e }) => {
4
- const t = ["relative py-3 font-semibold text-xs px-3"];
4
+ const t = ["relative p-2.5 font-medium"];
5
5
  return e.sortable && t.push("cursor-pointer hover:text-secondary-800 dark:hover:text-secondary-300 transition-colors duration-150 ease-in-out"), e.textAlign === "left" && t.push("text-left"), e.textAlign === "right" && t.push("text-right"), e.textAlign === "center" && t.push("text-center"), e.textAlign === "justify" && t.push("text-justify"), t;
6
6
  },
7
7
  sortIcon: ({ props: e }) => ["absolute stroke-2 w-3 h-3 top-3.5 right-0.5"]
@@ -1,15 +1,15 @@
1
- import { defineComponent as f, computed as g, openBlock as t, createBlock as b, resolveDynamicComponent as v, normalizeClass as a, unref as r, normalizeStyle as k, withCtx as x, createElementBlock as y, renderSlot as l, createVNode as z } from "vue";
2
- import { useColors as B } from "../../composables/useColors.js";
1
+ import { defineComponent as f, computed as g, openBlock as t, createBlock as v, resolveDynamicComponent as b, normalizeClass as a, unref as r, normalizeStyle as k, withCtx as x, createElementBlock as y, renderSlot as l, createElementVNode as z, createVNode as B } from "vue";
2
+ import { useColors as C } from "../../composables/useColors.js";
3
3
  import { useCommon as n } from "../../composables/useCommon.js";
4
- import { useTheme as C } from "../../composables/useTheme.js";
4
+ import { useTheme as h } from "../../composables/useTheme.js";
5
5
  import { closeIcon as S } from "../../common/icons.js";
6
- import $ from "../icon/Icon.vue.js";
7
- const h = {
6
+ import _ from "../icon/Icon.vue.js";
7
+ const $ = {
8
8
  key: 0,
9
- class: "max-w-full truncate"
10
- }, w = {
9
+ class: "max-w-full truncate pr-4"
10
+ }, w = { class: "absolute right-1.5 top-0 h-full flex items-center" }, N = {
11
11
  ...n.props(),
12
- ...B.props("slate"),
12
+ ...C.props("secondary"),
13
13
  tag: {
14
14
  type: String,
15
15
  default: "span"
@@ -23,15 +23,15 @@ const h = {
23
23
  validators: {
24
24
  ...n.validators()
25
25
  }
26
- }, V = /* @__PURE__ */ f({
26
+ }, j = /* @__PURE__ */ f({
27
27
  ...T,
28
- props: w,
28
+ props: N,
29
29
  emits: ["remove"],
30
30
  setup(d) {
31
- const o = d, i = g(() => o.size === "xs" ? "xs" : o.size === "sm" ? "sm" : o.size === "lg" ? "md" : o.size === "xl" ? "lg" : "sm"), { styles: m, classes: c, className: u } = C("Tag", {}, o);
32
- return (e, s) => (t(), b(v(e.tag), {
31
+ const o = d, i = g(() => o.size === "xs" ? "xs" : o.size === "sm" ? "sm" : o.size === "lg" ? "md" : o.size === "xl" ? "lg" : "sm"), { styles: m, classes: c, className: u } = h("Tag", {}, o);
32
+ return (e, s) => (t(), v(b(e.tag), {
33
33
  class: a([
34
- "text-[color:var(--x-tag-text)] dark:text-[color:var(--x-tag-dark-text)] border",
34
+ "text-[color:var(--x-tag-text)] dark:text-[color:var(--x-tag-dark-text)] border relative",
35
35
  [
36
36
  r(u),
37
37
  r(c).wrapper,
@@ -42,14 +42,16 @@ const h = {
42
42
  style: k(r(m))
43
43
  }, {
44
44
  default: x(() => [
45
- e.removable ? (t(), y("span", h, [
45
+ e.removable ? (t(), y("span", $, [
46
46
  l(e.$slots, "default"),
47
- z($, {
48
- size: i.value,
49
- icon: r(S),
50
- class: a(["ml-1.5 -mt-0.5 cursor-pointer transition-colors duration-150", [e.disabled ? "text-secondary-400" : "hover:text-secondary-500"]]),
51
- onClick: s[0] || (s[0] = (p) => !e.disabled && e.$emit("remove", p))
52
- }, null, 8, ["size", "icon", "class"])
47
+ z("div", w, [
48
+ B(_, {
49
+ size: i.value,
50
+ icon: r(S),
51
+ class: a(["cursor-pointer transition-colors duration-150", [e.disabled ? "text-secondary-400" : "hover:text-secondary-500"]]),
52
+ onClick: s[0] || (s[0] = (p) => !e.disabled && e.$emit("remove", p))
53
+ }, null, 8, ["size", "icon", "class"])
54
+ ])
53
55
  ])) : l(e.$slots, "default", { key: 1 })
54
56
  ]),
55
57
  _: 3
@@ -57,5 +59,5 @@ const h = {
57
59
  }
58
60
  });
59
61
  export {
60
- V as default
62
+ j as default
61
63
  };
@@ -1,5 +1,5 @@
1
1
  import { defineComponent as q, useAttrs as R, computed as A, ref as F, watch as H, openBlock as u, createBlock as p, normalizeStyle as K, unref as r, normalizeClass as L, withCtx as O, createElementVNode as $, mergeProps as D, toHandlers as W, withKeys as X, createCommentVNode as G } from "vue";
2
- import { useResizeObserver as J, useEventListener as M } from "../../node_modules/.pnpm/@vueuse_core@10.2.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/core/index.js";
2
+ import { useResizeObserver as J, useEventListener as M } from "../../node_modules/.pnpm/@vueuse_core@11.1.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/core/index.js";
3
3
  import { useCSS as Q } from "../../composables/useCSS.js";
4
4
  import { useTheme as U } from "../../composables/useTheme.js";
5
5
  import { useCommon as f } from "../../composables/useCommon.js";
@@ -0,0 +1,195 @@
1
+ import { type ExtractPublicPropTypes, type PropType } from 'vue';
2
+ import { type ThemeComponent } from '../../composables/useTheme';
3
+ declare const validators: {
4
+ variant: readonly ["box"];
5
+ size: string[];
6
+ };
7
+ declare const uploadProps: {
8
+ placeholder: StringConstructor;
9
+ accept: StringConstructor;
10
+ multiple: BooleanConstructor;
11
+ maxFiles: (StringConstructor | NumberConstructor)[];
12
+ maxFileSize: (StringConstructor | NumberConstructor)[];
13
+ variant: {
14
+ type: PropType<"box">;
15
+ default: string;
16
+ };
17
+ action: StringConstructor;
18
+ headers: PropType<Record<string, string>>;
19
+ method: {
20
+ type: PropType<"POST" | "PUT">;
21
+ default: string;
22
+ };
23
+ withCredentials: BooleanConstructor;
24
+ modelValue: {
25
+ readonly type: PropType<string | number | boolean | object | any[] | undefined>;
26
+ readonly default: undefined;
27
+ };
28
+ id: StringConstructor;
29
+ name: StringConstructor;
30
+ readonly: BooleanConstructor;
31
+ required: BooleanConstructor;
32
+ validateOnInput: {
33
+ readonly type: BooleanConstructor;
34
+ readonly default: true;
35
+ };
36
+ label: StringConstructor;
37
+ helper: StringConstructor;
38
+ error: StringConstructor;
39
+ hideFooter: BooleanConstructor;
40
+ rules: {
41
+ readonly type: ArrayConstructor;
42
+ readonly default: () => never[];
43
+ };
44
+ tooltip: StringConstructor;
45
+ skipFormRegistry: BooleanConstructor;
46
+ disabled: BooleanConstructor;
47
+ loading: BooleanConstructor;
48
+ loadingLabel: StringConstructor;
49
+ loadingStatus: {
50
+ readonly type: PropType<import("../loader/Loader.vue").LoaderStatus>;
51
+ readonly default: "active";
52
+ };
53
+ };
54
+ export type UploadFile = {
55
+ file: File;
56
+ completed: boolean;
57
+ response?: any;
58
+ progress: number;
59
+ error: string;
60
+ };
61
+ export type UploadVariant = typeof validators.variant[number];
62
+ export type UploadProps = ExtractPublicPropTypes<typeof uploadProps>;
63
+ type InternalClasses = 'wrapper' | 'input';
64
+ export interface UploadTheme extends ThemeComponent<UploadProps, InternalClasses> {
65
+ }
66
+ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
67
+ placeholder: StringConstructor;
68
+ accept: StringConstructor;
69
+ multiple: BooleanConstructor;
70
+ maxFiles: (StringConstructor | NumberConstructor)[];
71
+ maxFileSize: (StringConstructor | NumberConstructor)[];
72
+ variant: {
73
+ type: PropType<"box">;
74
+ default: string;
75
+ };
76
+ action: StringConstructor;
77
+ headers: PropType<Record<string, string>>;
78
+ method: {
79
+ type: PropType<"POST" | "PUT">;
80
+ default: string;
81
+ };
82
+ withCredentials: BooleanConstructor;
83
+ modelValue: {
84
+ readonly type: PropType<string | number | boolean | object | any[] | undefined>;
85
+ readonly default: undefined;
86
+ };
87
+ id: StringConstructor;
88
+ name: StringConstructor;
89
+ readonly: BooleanConstructor;
90
+ required: BooleanConstructor;
91
+ validateOnInput: {
92
+ readonly type: BooleanConstructor;
93
+ readonly default: true;
94
+ };
95
+ label: StringConstructor;
96
+ helper: StringConstructor;
97
+ error: StringConstructor;
98
+ hideFooter: BooleanConstructor;
99
+ rules: {
100
+ readonly type: ArrayConstructor;
101
+ readonly default: () => never[];
102
+ };
103
+ tooltip: StringConstructor;
104
+ skipFormRegistry: BooleanConstructor;
105
+ disabled: BooleanConstructor;
106
+ loading: BooleanConstructor;
107
+ loadingLabel: StringConstructor;
108
+ loadingStatus: {
109
+ readonly type: PropType<import("../loader/Loader.vue").LoaderStatus>;
110
+ readonly default: "active";
111
+ };
112
+ }>, {
113
+ focus: () => void | undefined;
114
+ blur: () => void | undefined;
115
+ reset: () => void;
116
+ validate: (val?: any) => boolean;
117
+ setError: (val: string) => void;
118
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, string[], string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
119
+ placeholder: StringConstructor;
120
+ accept: StringConstructor;
121
+ multiple: BooleanConstructor;
122
+ maxFiles: (StringConstructor | NumberConstructor)[];
123
+ maxFileSize: (StringConstructor | NumberConstructor)[];
124
+ variant: {
125
+ type: PropType<"box">;
126
+ default: string;
127
+ };
128
+ action: StringConstructor;
129
+ headers: PropType<Record<string, string>>;
130
+ method: {
131
+ type: PropType<"POST" | "PUT">;
132
+ default: string;
133
+ };
134
+ withCredentials: BooleanConstructor;
135
+ modelValue: {
136
+ readonly type: PropType<string | number | boolean | object | any[] | undefined>;
137
+ readonly default: undefined;
138
+ };
139
+ id: StringConstructor;
140
+ name: StringConstructor;
141
+ readonly: BooleanConstructor;
142
+ required: BooleanConstructor;
143
+ validateOnInput: {
144
+ readonly type: BooleanConstructor;
145
+ readonly default: true;
146
+ };
147
+ label: StringConstructor;
148
+ helper: StringConstructor;
149
+ error: StringConstructor;
150
+ hideFooter: BooleanConstructor;
151
+ rules: {
152
+ readonly type: ArrayConstructor;
153
+ readonly default: () => never[];
154
+ };
155
+ tooltip: StringConstructor;
156
+ skipFormRegistry: BooleanConstructor;
157
+ disabled: BooleanConstructor;
158
+ loading: BooleanConstructor;
159
+ loadingLabel: StringConstructor;
160
+ loadingStatus: {
161
+ readonly type: PropType<import("../loader/Loader.vue").LoaderStatus>;
162
+ readonly default: "active";
163
+ };
164
+ }>> & Readonly<{
165
+ [x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
166
+ }>, {
167
+ disabled: boolean;
168
+ loading: boolean;
169
+ loadingStatus: import("../loader/Loader.vue").LoaderStatus;
170
+ modelValue: string | number | boolean | object | any[] | undefined;
171
+ readonly: boolean;
172
+ required: boolean;
173
+ validateOnInput: boolean;
174
+ hideFooter: boolean;
175
+ rules: unknown[];
176
+ skipFormRegistry: boolean;
177
+ variant: "box";
178
+ multiple: boolean;
179
+ method: "POST" | "PUT";
180
+ withCredentials: boolean;
181
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, {
182
+ box?(_: {
183
+ isOver: boolean;
184
+ }): any;
185
+ files?(_: {
186
+ files: (string | number | boolean | object | any[] | undefined) & UploadFile[];
187
+ }): any;
188
+ removeIcon?(_: {}): any;
189
+ }>;
190
+ export default _default;
191
+ type __VLS_WithTemplateSlots<T, S> = T & {
192
+ new (): {
193
+ $slots: S;
194
+ };
195
+ };
@@ -0,0 +1,264 @@
1
+ import { defineComponent as te, ref as y, computed as oe, watch as ne, openBlock as d, createElementBlock as f, normalizeClass as b, unref as s, createVNode as x, normalizeStyle as se, withCtx as ie, createElementVNode as l, mergeProps as ae, toHandlers as le, renderSlot as k, toDisplayString as _, createBlock as g, createCommentVNode as w, Fragment as de, renderList as ce } from "vue";
2
+ import { useDropZone as ue } from "../../node_modules/.pnpm/@vueuse_core@11.1.0_vue@3.5.10_typescript@5.2.2_/node_modules/@vueuse/core/index.js";
3
+ import { useCommon as pe } from "../../composables/useCommon.js";
4
+ import { useInteractive as U } from "../../composables/useInteractive.js";
5
+ import { useInputtable as I } from "../../composables/useInputtable.js";
6
+ import { useTheme as me } from "../../composables/useTheme.js";
7
+ import { uploadIcon as fe, fileIcon as ge, closeIcon as he } from "../../common/icons.js";
8
+ import ve from "../label/Label.vue.js";
9
+ import O from "../inputFooter/InputFooter.vue.js";
10
+ import ye from "../progress/Progress.vue.js";
11
+ import S from "../icon/Icon.vue.js";
12
+ const be = ["id", "disabled", "name", "accept", "multiple", "readonly"], xe = { class: "text-secondary-500 dark:text-secondary-400" }, ke = { class: "flex items-center" }, _e = ["src"], we = { class: "truncate flex-1 pr-2" }, Se = { class: "font-medium truncate" }, Ie = { class: "text-xs text-secondary-500" }, $e = ["onClick"], Ve = {
13
+ ...pe.validators(),
14
+ variant: ["box"]
15
+ }, Ce = {
16
+ ...U.props(),
17
+ ...I.props(),
18
+ placeholder: String,
19
+ accept: String,
20
+ multiple: Boolean,
21
+ maxFiles: [Number, String],
22
+ maxFileSize: [Number, String],
23
+ variant: {
24
+ type: String,
25
+ default: "box"
26
+ },
27
+ // URL to submit data to.
28
+ action: String,
29
+ // Additional HTTP headers
30
+ headers: Object,
31
+ method: {
32
+ type: String,
33
+ default: "POST"
34
+ },
35
+ withCredentials: Boolean
36
+ }, Ee = {
37
+ name: "XUpload",
38
+ validators: Ve
39
+ }, Fe = /* @__PURE__ */ te({
40
+ ...Ee,
41
+ props: Ce,
42
+ emits: [...I.emits(), "upload", "remove"],
43
+ setup(j, { expose: D, emit: q }) {
44
+ const o = j, u = q, $ = y(null), p = oe(() => !!o.action), i = y([]);
45
+ ne(i, (e) => {
46
+ u("update:modelValue", e);
47
+ }, { deep: !0, immediate: !0 });
48
+ const { focus: V, blur: P } = U($);
49
+ function h(e) {
50
+ if (!e)
51
+ return !1;
52
+ if (!o.multiple && e.length > 1 || o.maxFiles && e.length > Number(o.maxFiles))
53
+ return m.value = "Too many files", !1;
54
+ if (o.maxFileSize) {
55
+ for (let t = 0; t < e.length; t++)
56
+ if (e[t].size > Number(o.maxFileSize))
57
+ return m.value = "File size is too large", !1;
58
+ }
59
+ if (o.accept) {
60
+ const t = o.accept.split(",").map((r) => r.trim());
61
+ for (let r = 0; r < e.length; r++) {
62
+ const n = e[r];
63
+ if (!t.some((c) => n.type === c || n.name.endsWith(c)))
64
+ return m.value = "Invalid file type", !1;
65
+ }
66
+ }
67
+ return !0;
68
+ }
69
+ function T(e) {
70
+ const r = e.target.files;
71
+ h(r) && u("change", e);
72
+ }
73
+ function F(e) {
74
+ const r = e.target.files;
75
+ h(r) && (N(r), o.validateOnInput && !K.value && v(i.value), u("input", e));
76
+ }
77
+ const C = y(null);
78
+ function M(e) {
79
+ h(e) && N(e);
80
+ }
81
+ const { isOverDropZone: E } = ue(C, {
82
+ onDrop: M,
83
+ multiple: o.multiple,
84
+ preventDefaultForUnhandled: !1
85
+ });
86
+ function N(e) {
87
+ i.value = e ? Array.from(e).map((t) => ({
88
+ file: t,
89
+ completed: !p.value,
90
+ progress: p.value ? 0 : 100,
91
+ error: ""
92
+ })) : [], p.value && W();
93
+ }
94
+ function Z(e) {
95
+ const t = i.value.findIndex((r) => r.file === e);
96
+ t !== -1 && (u("remove", i.value[t]), i.value.splice(t, 1));
97
+ }
98
+ function B(e) {
99
+ const t = ["jpg", "jpeg", "png", "gif", "webp", "svg"];
100
+ return e.type.startsWith("image") || t.some((r) => e.name.endsWith(r));
101
+ }
102
+ function z(e) {
103
+ return URL.createObjectURL(e);
104
+ }
105
+ function A(e) {
106
+ return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(2)} KB` : e < 1024 * 1024 * 1024 ? `${(e / 1024 / 1024).toFixed(2)} MB` : `${(e / 1024 / 1024 / 1024).toFixed(2)} GB`;
107
+ }
108
+ async function H(e) {
109
+ return new Promise((t, r) => {
110
+ if (!o.action)
111
+ r(new Error("No action provided"));
112
+ else {
113
+ const n = new XMLHttpRequest(), c = new FormData();
114
+ c.append("file", e.file), n.open(o.method, o.action, !0), o.headers && typeof o.headers == "object" && Object.keys(o.headers).forEach((a) => {
115
+ n.setRequestHeader(a, o.headers[a]);
116
+ }), n.upload.addEventListener("progress", (a) => {
117
+ if (a.lengthComputable) {
118
+ const L = a.loaded / a.total * 100;
119
+ e.progress = L, console.log(`Upload progress: ${L}%`);
120
+ }
121
+ }), n.addEventListener("load", () => {
122
+ if (n.status === 200) {
123
+ e.completed = !0;
124
+ try {
125
+ e.response = JSON.parse(n.responseText);
126
+ } catch {
127
+ e.response = n.responseText;
128
+ }
129
+ t(n.responseText);
130
+ } else {
131
+ const a = `Upload failed. Status: ${n.status}`;
132
+ e.error = a, r(new Error(a));
133
+ }
134
+ }), n.addEventListener("error", () => {
135
+ e.error = "An error occurred during the upload.", r(new Error("An error occurred during the upload."));
136
+ }), n.send(c);
137
+ }
138
+ });
139
+ }
140
+ async function W() {
141
+ if (!o.action && !i.value)
142
+ return;
143
+ const e = [];
144
+ for (let t = 0; t < i.value.length; t++)
145
+ e.push(H(i.value[t]));
146
+ await Promise.all(e), v(i.value);
147
+ }
148
+ const {
149
+ errorInternal: m,
150
+ hideFooterInternal: X,
151
+ isInsideForm: G,
152
+ inputListeners: J,
153
+ isFirstValidation: K,
154
+ reset: Q,
155
+ validate: v,
156
+ setError: Y
157
+ } = I(o, { focus: V, emit: u }), { styles: ee, classes: R, className: re } = me("Upload", {}, o);
158
+ return D({ focus: V, blur: P, reset: Q, validate: v, setError: Y }), (e, t) => (d(), f("div", {
159
+ class: b([
160
+ s(re),
161
+ s(R).wrapper
162
+ ])
163
+ }, [
164
+ x(ve, {
165
+ style: se(s(ee)),
166
+ disabled: e.disabled,
167
+ required: e.required,
168
+ "is-inside-form": s(G),
169
+ label: e.label,
170
+ tooltip: e.tooltip
171
+ }, {
172
+ default: ie(() => [
173
+ l("input", ae({
174
+ id: e.id,
175
+ ref_key: "elRef",
176
+ ref: $,
177
+ type: "file",
178
+ class: [
179
+ "sr-only",
180
+ s(R).input
181
+ ],
182
+ disabled: e.disabled,
183
+ name: e.name,
184
+ accept: e.accept,
185
+ multiple: e.multiple,
186
+ readonly: e.readonly
187
+ }, le({
188
+ ...s(J),
189
+ input: F,
190
+ change: T
191
+ }, !0)), null, 16, be),
192
+ k(e.$slots, "box", { isOver: s(E) }, () => [
193
+ l("div", {
194
+ ref_key: "dropZoneRef",
195
+ ref: C,
196
+ class: b(["border border-dashed rounded-md flex items-center justify-center gap-2 p-4 cursor-pointer transition-colors duration-500 hover:border-primary-500 dark:hover:border-primary-400", {
197
+ "border-primary-500 dark:border-primary-400": s(E)
198
+ }])
199
+ }, [
200
+ x(S, { icon: s(fe) }, null, 8, ["icon"]),
201
+ l("span", xe, _(e.placeholder), 1),
202
+ t[0] || (t[0] = l("span", { class: "text-xs text-secondary-400 dark:text-secondary-500" }, "or drag and drop", -1))
203
+ ], 2)
204
+ ]),
205
+ s(X) ? w("", !0) : (d(), g(O, {
206
+ key: 0,
207
+ error: s(m),
208
+ helper: e.helper
209
+ }, null, 8, ["error", "helper"]))
210
+ ]),
211
+ _: 3
212
+ }, 8, ["style", "disabled", "required", "is-inside-form", "label", "tooltip"]),
213
+ k(e.$slots, "files", { files: i.value }, () => [
214
+ (d(!0), f(de, null, ce(i.value, (r, n) => (d(), f("div", {
215
+ key: n,
216
+ class: "border rounded-md p-2 bg-secondary-100 my-2"
217
+ }, [
218
+ l("div", ke, [
219
+ l("div", {
220
+ class: b(["rounded-md w-9 h-9 flex items-center justify-center mr-2 border", {
221
+ "p-2 bg-white": !B(r.file)
222
+ }])
223
+ }, [
224
+ B(r.file) ? (d(), f("img", {
225
+ key: 0,
226
+ src: z(r.file),
227
+ class: "w-full h-full object-cover rounded-md"
228
+ }, null, 8, _e)) : (d(), g(S, {
229
+ key: 1,
230
+ icon: s(ge)
231
+ }, null, 8, ["icon"]))
232
+ ], 2),
233
+ l("div", we, [
234
+ l("div", Se, _(r.file.name), 1),
235
+ l("div", Ie, _(A(r.file.size)), 1)
236
+ ]),
237
+ l("button", {
238
+ type: "button",
239
+ class: "shrink-0",
240
+ onClick: (c) => Z(r.file)
241
+ }, [
242
+ k(e.$slots, "removeIcon", {}, () => [
243
+ x(S, { icon: s(he) }, null, 8, ["icon"])
244
+ ])
245
+ ], 8, $e)
246
+ ]),
247
+ p.value ? (d(), g(ye, {
248
+ key: 0,
249
+ percentage: r.progress,
250
+ class: "mt-1",
251
+ color: r.error ? "warning" : "success"
252
+ }, null, 8, ["percentage", "color"])) : w("", !0),
253
+ r.error ? (d(), g(O, {
254
+ key: 1,
255
+ error: r.error
256
+ }, null, 8, ["error"])) : w("", !0)
257
+ ]))), 128))
258
+ ])
259
+ ], 2));
260
+ }
261
+ });
262
+ export {
263
+ Fe as default
264
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./Upload.vue.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export { default as XUpload } from './Upload.vue';
2
+ export type { UploadProps, UploadFile, UploadTheme } from './Upload.vue';
@@ -0,0 +1,3 @@
1
+ import type { UploadTheme } from '../Upload.vue';
2
+ declare const theme: UploadTheme;
3
+ export default theme;
@@ -0,0 +1,8 @@
1
+ const e = {
2
+ classes: {
3
+ wrapper: ""
4
+ }
5
+ }, s = e;
6
+ export {
7
+ s as default
8
+ };
@@ -0,0 +1,3 @@
1
+ import type { UploadTheme } from '../Upload.vue';
2
+ declare const theme: UploadTheme;
3
+ export default theme;
@@ -0,0 +1,5 @@
1
+ import e from "./Upload.base.theme.js";
2
+ const t = e, o = t;
3
+ export {
4
+ o as default
5
+ };