bromcom-ui 3.0.0-alpha.3 → 3.0.0-alpha.5

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 (156) hide show
  1. package/dist/bromcom-ui/bromcom-ui.css +1 -1
  2. package/dist/bromcom-ui/bromcom-ui.esm.js +1 -1
  3. package/dist/bromcom-ui/p-01eaca9a.entry.js +5 -0
  4. package/dist/bromcom-ui/{p-dc8b7bd5.entry.js → p-0b7de283.entry.js} +1 -1
  5. package/dist/bromcom-ui/{p-ff8adde6.entry.js → p-0e75f6ba.entry.js} +1 -1
  6. package/dist/bromcom-ui/{p-3a6e9576.entry.js → p-112b9a62.entry.js} +1 -1
  7. package/dist/bromcom-ui/{p-be96827e.js → p-1535f9b1.js} +1 -1
  8. package/dist/bromcom-ui/{p-ef839034.entry.js → p-32ce6cf6.entry.js} +1 -1
  9. package/dist/bromcom-ui/{p-33d97b3f.entry.js → p-33b2ed75.entry.js} +1 -1
  10. package/dist/bromcom-ui/p-3ddd3c83.entry.js +5 -0
  11. package/dist/bromcom-ui/{p-e115af8a.entry.js → p-4545a13d.entry.js} +1 -1
  12. package/dist/bromcom-ui/{p-f1de8ed5.entry.js → p-5532696c.entry.js} +1 -1
  13. package/dist/bromcom-ui/{p-f6e710ff.entry.js → p-69adb859.entry.js} +1 -1
  14. package/dist/bromcom-ui/{p-d0647951.js → p-6ce02d0a.js} +1 -1
  15. package/dist/bromcom-ui/p-7c08789d.entry.js +5 -0
  16. package/dist/bromcom-ui/{p-b7f449ff.entry.js → p-803739bc.entry.js} +1 -1
  17. package/dist/bromcom-ui/{p-3b988ad1.entry.js → p-8390dd02.entry.js} +1 -1
  18. package/dist/bromcom-ui/p-91197b04.js +5 -0
  19. package/dist/bromcom-ui/{p-b9b9d753.entry.js → p-a80e6310.entry.js} +1 -1
  20. package/dist/bromcom-ui/p-aa67918a.entry.js +5 -0
  21. package/dist/bromcom-ui/{p-91aa21af.entry.js → p-acab07ec.entry.js} +1 -1
  22. package/dist/bromcom-ui/{p-a53c3682.entry.js → p-b333a3d7.entry.js} +1 -1
  23. package/dist/bromcom-ui/{p-b386e9c9.entry.js → p-b7787c11.entry.js} +1 -1
  24. package/dist/bromcom-ui/{p-2e7ffc5a.entry.js → p-b7c56cbe.entry.js} +1 -1
  25. package/dist/bromcom-ui/{p-221095a9.entry.js → p-c36a7889.entry.js} +1 -1
  26. package/dist/bromcom-ui/p-ce0ab4e3.entry.js +5 -0
  27. package/dist/bromcom-ui/{p-ee75cd00.js → p-d3cf91a9.js} +1 -1
  28. package/dist/bromcom-ui/p-d5464577.entry.js +16 -0
  29. package/dist/bromcom-ui/{p-bd77f532.entry.js → p-d7a619c5.entry.js} +1 -1
  30. package/dist/bromcom-ui/{p-baa4193d.entry.js → p-e36b6b08.entry.js} +1 -1
  31. package/dist/bromcom-ui/{p-6c7fdf95.entry.js → p-f15c1d3d.entry.js} +1 -1
  32. package/dist/bromcom-ui/{p-8001040c.js → p-fc29c94d.js} +1 -1
  33. package/dist/cjs/bcm-accordion_69.cjs.entry.js +722 -66
  34. package/dist/cjs/bcm-attendance-actions-comment.cjs.entry.js +4 -4
  35. package/dist/cjs/bcm-attendance-actions-dropdown.cjs.entry.js +4 -4
  36. package/dist/cjs/bcm-breadcrumb.cjs.entry.js +2 -2
  37. package/dist/cjs/bcm-caption.cjs.entry.js +4 -4
  38. package/dist/cjs/bcm-card.cjs.entry.js +2 -2
  39. package/dist/cjs/bcm-date-picker.cjs.entry.js +2 -2
  40. package/dist/cjs/bcm-datetime-picker.cjs.entry.js +2 -2
  41. package/dist/cjs/bcm-default.cjs.entry.js +2 -2
  42. package/dist/cjs/bcm-file-upload.cjs.entry.js +578 -0
  43. package/dist/cjs/bcm-form-2.cjs.entry.js +3 -2
  44. package/dist/cjs/bcm-input-2.cjs.entry.js +2 -2
  45. package/dist/cjs/bcm-input-custom.cjs.entry.js +2 -2
  46. package/dist/cjs/bcm-input-dropdown.cjs.entry.js +4 -4
  47. package/dist/cjs/bcm-modal-2-footer.cjs.entry.js +4 -4
  48. package/dist/cjs/bcm-modal-2-header.cjs.entry.js +4 -4
  49. package/dist/cjs/bcm-modal-2.cjs.entry.js +4 -4
  50. package/dist/cjs/bcm-number-input.cjs.entry.js +12 -6
  51. package/dist/cjs/bcm-skeleton.cjs.entry.js +4 -4
  52. package/dist/cjs/bcm-table.cjs.entry.js +4 -4
  53. package/dist/cjs/bcm-tag.cjs.entry.js +3 -3
  54. package/dist/cjs/bcm-time-picker.cjs.entry.js +2 -2
  55. package/dist/cjs/bcm-toast.cjs.entry.js +17 -11
  56. package/dist/cjs/bromcom-ui.cjs.js +3 -3
  57. package/dist/cjs/{generate-554f54dc.js → generate-9d1bf6b3.js} +1 -1
  58. package/dist/cjs/{global-90b5dbce.js → global-d69a64ec.js} +1 -1
  59. package/dist/cjs/loader.cjs.js +3 -3
  60. package/dist/cjs/{number-helper-677e9c02.js → number-helper-ae28b255.js} +1 -1
  61. package/dist/cjs/old-bcm-popover-box.cjs.entry.js +3 -3
  62. package/dist/cjs/old-bcm-popover.cjs.entry.js +2 -2
  63. package/dist/cjs/{package-8445ccd4.js → package-6de220be.js} +1 -1
  64. package/dist/cjs/{validators-92f2f1ef.js → validators-3381bee2.js} +1 -1
  65. package/dist/collection/collection-manifest.json +1 -0
  66. package/dist/collection/components/atoms/button/button.js +1 -1
  67. package/dist/collection/components/atoms/button/types.js +7 -0
  68. package/dist/collection/components/molecules/color-input/color-input.js +5 -22
  69. package/dist/collection/components/molecules/color-palette/color-palette.js +4 -4
  70. package/dist/collection/components/molecules/dropdown/dropdown.js +36 -1
  71. package/dist/collection/components/molecules/linked/linked-focus-manager.js +86 -0
  72. package/dist/collection/components/molecules/linked/linked.js +43 -1
  73. package/dist/collection/components/molecules/number-input/number-input.js +8 -2
  74. package/dist/collection/components/molecules/number-input/react-input.js +1 -1
  75. package/dist/collection/components/molecules/upload/file-upload.component.js +1060 -0
  76. package/dist/collection/components/molecules/upload/file-upload.style.js +201 -0
  77. package/dist/collection/components/organism/form/form.js +1 -0
  78. package/dist/collection/components/organism/form-2/bcm-form-components.js +1 -0
  79. package/dist/collection/components/organism/list/list-focus-manager.js +344 -0
  80. package/dist/collection/components/organism/list/list-key-control.js +9 -4
  81. package/dist/collection/components/organism/list/list.css +8 -3
  82. package/dist/collection/components/organism/list/list.js +227 -27
  83. package/dist/collection/components/other/toast/toast.js +15 -9
  84. package/dist/collection/components/other_deprecated/old-tag/old-tag.js +1 -1
  85. package/dist/collection/components/other_deprecated/tag/tag.js +1 -1
  86. package/dist/collection/templates/list-item-template.js +6 -5
  87. package/dist/collection/templates/list-template.js +2 -2
  88. package/dist/components/bcm-color-input.js +5 -22
  89. package/dist/components/bcm-dropdown.js +35 -0
  90. package/dist/components/bcm-file-upload.d.ts +11 -0
  91. package/dist/components/bcm-file-upload.js +625 -0
  92. package/dist/components/bcm-form-2.js +1 -0
  93. package/dist/components/bcm-number-input.js +8 -2
  94. package/dist/components/bcm-toast.js +15 -9
  95. package/dist/components/button.js +7 -0
  96. package/dist/components/color-palette.js +2 -2
  97. package/dist/components/form.js +1 -0
  98. package/dist/components/generate.js +1 -1
  99. package/dist/components/index.d.ts +1 -0
  100. package/dist/components/index.js +1 -0
  101. package/dist/components/linked.js +105 -2
  102. package/dist/components/list.js +567 -39
  103. package/dist/esm/bcm-accordion_69.entry.js +722 -66
  104. package/dist/esm/bcm-attendance-actions-comment.entry.js +4 -4
  105. package/dist/esm/bcm-attendance-actions-dropdown.entry.js +4 -4
  106. package/dist/esm/bcm-breadcrumb.entry.js +2 -2
  107. package/dist/esm/bcm-caption.entry.js +4 -4
  108. package/dist/esm/bcm-card.entry.js +2 -2
  109. package/dist/esm/bcm-date-picker.entry.js +2 -2
  110. package/dist/esm/bcm-datetime-picker.entry.js +2 -2
  111. package/dist/esm/bcm-default.entry.js +2 -2
  112. package/dist/esm/bcm-file-upload.entry.js +574 -0
  113. package/dist/esm/bcm-form-2.entry.js +3 -2
  114. package/dist/esm/bcm-input-2.entry.js +2 -2
  115. package/dist/esm/bcm-input-custom.entry.js +2 -2
  116. package/dist/esm/bcm-input-dropdown.entry.js +4 -4
  117. package/dist/esm/bcm-modal-2-footer.entry.js +4 -4
  118. package/dist/esm/bcm-modal-2-header.entry.js +4 -4
  119. package/dist/esm/bcm-modal-2.entry.js +4 -4
  120. package/dist/esm/bcm-number-input.entry.js +12 -6
  121. package/dist/esm/bcm-skeleton.entry.js +4 -4
  122. package/dist/esm/bcm-table.entry.js +4 -4
  123. package/dist/esm/bcm-tag.entry.js +3 -3
  124. package/dist/esm/bcm-time-picker.entry.js +2 -2
  125. package/dist/esm/bcm-toast.entry.js +17 -11
  126. package/dist/esm/bromcom-ui.js +3 -3
  127. package/dist/esm/{generate-8a394b83.js → generate-56d49b70.js} +1 -1
  128. package/dist/esm/{global-7919f57f.js → global-97c42a5f.js} +1 -1
  129. package/dist/esm/loader.js +3 -3
  130. package/dist/esm/{number-helper-a86adc72.js → number-helper-455ab41e.js} +1 -1
  131. package/dist/esm/old-bcm-popover-box.entry.js +3 -3
  132. package/dist/esm/old-bcm-popover.entry.js +2 -2
  133. package/dist/esm/{package-278e08d9.js → package-edee14d5.js} +1 -1
  134. package/dist/esm/{validators-89e791a1.js → validators-cc882165.js} +1 -1
  135. package/dist/types/components/atoms/button/types.d.ts +8 -1
  136. package/dist/types/components/molecules/color-input/color-input.d.ts +1 -4
  137. package/dist/types/components/molecules/dropdown/dropdown.d.ts +7 -0
  138. package/dist/types/components/molecules/linked/linked-focus-manager.d.ts +13 -0
  139. package/dist/types/components/molecules/linked/linked.d.ts +3 -0
  140. package/dist/types/components/molecules/number-input/number-input.d.ts +1 -0
  141. package/dist/types/components/molecules/upload/file-upload.component.d.ts +233 -0
  142. package/dist/types/components/molecules/upload/file-upload.style.d.ts +548 -0
  143. package/dist/types/components/organism/list/list-focus-manager.d.ts +53 -0
  144. package/dist/types/components/organism/list/list-key-control.d.ts +1 -0
  145. package/dist/types/components/organism/list/list.d.ts +18 -1
  146. package/dist/types/components/other/toast/toast.d.ts +1 -0
  147. package/dist/types/components.d.ts +417 -1
  148. package/dist/types/templates/list-item-template.d.ts +2 -0
  149. package/dist/types/templates/list-template.d.ts +2 -0
  150. package/package.json +1 -1
  151. package/dist/bromcom-ui/p-16b8a312.entry.js +0 -16
  152. package/dist/bromcom-ui/p-839b6fd5.entry.js +0 -5
  153. package/dist/bromcom-ui/p-be8aa3b8.entry.js +0 -5
  154. package/dist/bromcom-ui/p-d0aa71e1.entry.js +0 -5
  155. package/dist/bromcom-ui/p-df92d838.js +0 -5
  156. package/dist/bromcom-ui/p-dfd73f7c.entry.js +0 -5
@@ -0,0 +1,578 @@
1
+ /*!
2
+ * Built with Stencil
3
+ * Copyright (c) Bromcom.
4
+ */
5
+ 'use strict';
6
+
7
+ Object.defineProperty(exports, '__esModule', { value: true });
8
+
9
+ const index$1 = require('./index-c591ecec.js');
10
+ const generate = require('./generate-9d1bf6b3.js');
11
+ const index = require('./index-5279dea2.js');
12
+ const captionTemplate = require('./caption-template-f8a78504.js');
13
+ require('./package-6de220be.js');
14
+ require('./colors-250d0982.js');
15
+ require('./_commonjsHelpers-ed84c3ca.js');
16
+ require('./index-95ae50d0.js');
17
+
18
+ const zoneDefaultSurface = 'tw-border-dashed tw-border-color tw-bg-color-default';
19
+ const zoneHoverSurface = '!tw-border-solid !tw-border-color-primaryInfo';
20
+ const zoneDragSurface = '!tw-border-solid !tw-border-color-primaryInfo !tw-bg-primary-50';
21
+ const uploadClasses = index.ce({
22
+ slots: {
23
+ container: 'bcm-ui-element tw-flex tw-flex-col tw-w-full',
24
+ label: 'tw-text-3 tw-font-medium tw-text-color-label tw-leading-5',
25
+ triggerWrap: 'tw-flex tw-flex-col tw-w-full',
26
+ zone: [
27
+ 'tw-relative tw-rounded tw-border tw-transition-all tw-duration-200 tw-ease-in-out',
28
+ 'tw-select-none tw-flex tw-items-center tw-justify-center',
29
+ zoneDefaultSurface,
30
+ ],
31
+ iconContainer: 'tw-flex tw-shrink-0 tw-items-center tw-justify-center',
32
+ iconSizeClass: 'tw-block tw-text-color-default',
33
+ zoneTextWrapper: 'tw-flex tw-flex-col tw-flex-1 tw-min-w-0',
34
+ zoneTextMain: 'tw-text-3 tw-font-medium tw-text-color-caption tw-leading-tight',
35
+ zoneLink: 'tw-text-color-primary tw-font-medium hover:tw-underline tw-cursor-pointer',
36
+ zoneTextSub: 'tw-text-2 tw-text-color-caption tw-leading-4',
37
+ list: 'tw-flex tw-flex-col tw-gap-2',
38
+ fileRow: [
39
+ 'tw-flex tw-flex-col tw-rounded tw-min-w-0',
40
+ 'tw-bg-color-default tw-px-4 tw-py-2',
41
+ ],
42
+ fileRowHeader: 'tw-flex tw-items-center tw-gap-2 tw-w-full tw-min-w-0',
43
+ fileIcon: 'tw-shrink-0 tw-text-color-primary',
44
+ fileTitle: 'tw-font-medium tw-leading-5 tw-text-color-default tw-truncate tw-flex-1 tw-min-w-0',
45
+ progressWrapper: 'tw-flex tw-items-center tw-gap-2 tw-w-full',
46
+ progressTrack: 'tw-flex-1 tw-h-2 tw-bg-color-default-hover tw-rounded-full tw-overflow-hidden',
47
+ progressBar: 'tw-h-full tw-bg-primary-600 tw-rounded-full tw-transition-all tw-duration-300 tw-ease-out',
48
+ percent: 'tw-text-3 tw-font-medium tw-leading-5 tw-text-color-default tw-min-w-[3ch] tw-text-right tw-shrink-0',
49
+ actions: 'tw-flex tw-items-center tw-shrink-0',
50
+ iconBtn: [
51
+ 'tw-flex tw-items-center tw-justify-center tw-transition-colors tw-cursor-pointer',
52
+ 'tw-appearance-none tw-border-none tw-bg-transparent tw-p-0',
53
+ 'tw-text-color-default hover:tw-text-color-primary',
54
+ ],
55
+ errorArea: [
56
+ 'tw-flex tw-items-center tw-gap-3 tw-py-1.5 tw-px-3 tw-rounded',
57
+ 'tw-bg-red-50 tw-text-color-error tw-text-3 tw-font-medium tw-leading-none',
58
+ ],
59
+ errorIcon: 'tw-flex tw-items-center tw-justify-center tw-shrink-0',
60
+ errorClose: 'tw-ml-auto tw-cursor-pointer hover:tw-opacity-80',
61
+ captionWrap: '[&_.bcm-caption-area]:!tw-mt-0',
62
+ },
63
+ variants: {
64
+ size: {
65
+ medium: {
66
+ container: 'tw-gap-1',
67
+ zone: 'tw-gap-2 tw-px-4 tw-py-4',
68
+ zoneTextWrapper: 'tw-gap-1',
69
+ fileRow: 'tw-gap-1 tw-px-4 tw-py-2',
70
+ fileRowHeader: 'tw-gap-2',
71
+ fileIcon: 'tw-text-4',
72
+ fileTitle: 'tw-text-3',
73
+ iconBtn: 'tw-text-4',
74
+ progressWrapper: 'tw-gap-2',
75
+ progressTrack: 'tw-h-2',
76
+ },
77
+ small: {
78
+ container: 'tw-gap-0.5',
79
+ zone: 'tw-gap-2 tw-px-3 tw-py-3',
80
+ zoneTextWrapper: 'tw-gap-0.5',
81
+ fileRow: 'tw-gap-0.5 tw-px-3 tw-py-1',
82
+ fileRowHeader: 'tw-gap-1',
83
+ fileTitle: 'tw-text-2',
84
+ fileIcon: 'tw-text-3',
85
+ percent: 'tw-text-2',
86
+ iconBtn: 'tw-text-3',
87
+ progressWrapper: 'tw-gap-1',
88
+ progressTrack: 'tw-h-1.5',
89
+ list: 'tw-gap-1.5',
90
+ },
91
+ },
92
+ position: {
93
+ vertical: {
94
+ zone: 'tw-flex-col tw-text-center',
95
+ zoneTextWrapper: 'tw-items-center',
96
+ zoneTextSub: 'tw-text-center',
97
+ },
98
+ horizontal: {
99
+ zone: 'tw-flex-row tw-text-left',
100
+ zoneTextWrapper: 'tw-items-start',
101
+ },
102
+ button: {
103
+ container: 'tw-gap-1',
104
+ },
105
+ },
106
+ disabled: {
107
+ true: '',
108
+ false: '',
109
+ },
110
+ zoneHovered: {
111
+ true: '',
112
+ false: '',
113
+ },
114
+ dragActive: {
115
+ true: '',
116
+ false: '',
117
+ },
118
+ zoneError: {
119
+ true: '',
120
+ false: '',
121
+ },
122
+ fullWidth: {
123
+ true: {
124
+ container: 'tw-max-w-full',
125
+ },
126
+ false: {
127
+ container: 'tw-max-w-64',
128
+ },
129
+ },
130
+ },
131
+ compoundVariants: [
132
+ {
133
+ position: ['vertical', 'horizontal'],
134
+ size: 'medium',
135
+ class: {
136
+ iconContainer: 'tw-h-10',
137
+ iconSizeClass: 'tw-text-[40px] tw-leading-none',
138
+ },
139
+ },
140
+ {
141
+ position: 'vertical',
142
+ size: 'small',
143
+ class: {
144
+ iconContainer: 'tw-size-8',
145
+ iconSizeClass: 'tw-text-[32px] tw-leading-none',
146
+ },
147
+ },
148
+ {
149
+ position: 'horizontal',
150
+ size: 'small',
151
+ class: {
152
+ iconContainer: 'tw-h-8 tw-max-h-8 tw-max-w-9',
153
+ iconSizeClass: '!tw-text-[28px] !tw-leading-none',
154
+ },
155
+ },
156
+ {
157
+ position: ['vertical', 'horizontal'],
158
+ disabled: false,
159
+ class: {
160
+ zone: 'tw-cursor-pointer',
161
+ },
162
+ },
163
+ {
164
+ position: ['vertical', 'horizontal'],
165
+ disabled: false,
166
+ zoneError: false,
167
+ zoneHovered: true,
168
+ dragActive: false,
169
+ class: {
170
+ zone: zoneHoverSurface,
171
+ },
172
+ },
173
+ {
174
+ position: ['vertical', 'horizontal'],
175
+ disabled: false,
176
+ zoneError: false,
177
+ dragActive: true,
178
+ class: {
179
+ zone: zoneDragSurface,
180
+ },
181
+ },
182
+ {
183
+ position: ['vertical', 'horizontal'],
184
+ zoneError: true,
185
+ disabled: false,
186
+ class: {
187
+ zone: '!tw-border-solid tw-border-color-error !tw-bg-red-50',
188
+ },
189
+ },
190
+ {
191
+ disabled: true,
192
+ class: {
193
+ zone: [
194
+ 'tw-cursor-not-allowed',
195
+ 'tw-border-dashed tw-border-color-disabled tw-bg-color-disabled',
196
+ ],
197
+ zoneTextMain: 'tw-text-color-disabled',
198
+ zoneTextSub: 'tw-text-color-disabled',
199
+ zoneLink: 'tw-text-color-disabled tw-cursor-not-allowed tw-no-underline hover:tw-no-underline',
200
+ iconSizeClass: '!tw-text-color-disabled',
201
+ },
202
+ },
203
+ ],
204
+ defaultVariants: {
205
+ size: 'medium',
206
+ position: 'vertical',
207
+ disabled: false,
208
+ zoneHovered: false,
209
+ dragActive: false,
210
+ zoneError: false,
211
+ fullWidth: false,
212
+ },
213
+ });
214
+
215
+ const BcmFileUpload = class {
216
+ constructor(hostRef) {
217
+ index$1.registerInstance(this, hostRef);
218
+ this.bcmFileChange = index$1.createEvent(this, "bcm-file-change", 1);
219
+ this.bcmChange = index$1.createEvent(this, "bcm-change", 7);
220
+ this.bcmFileRemoved = index$1.createEvent(this, "bcm-file-removed", 1);
221
+ this.bcmUploadCanceled = index$1.createEvent(this, "bcm-upload-canceled", 1);
222
+ this.bcmFocus = index$1.createEvent(this, "bcm-focus", 1);
223
+ this.bcmBlur = index$1.createEvent(this, "bcm-blur", 1);
224
+ this.inputId = generate.Generate.UID();
225
+ this.labelId = generate.Generate.UID();
226
+ this.internalMaxSizeInBytes = this.maxSize * 1024 * 1024;
227
+ this.onFileInputChange = (event) => {
228
+ const input = event.target;
229
+ this.addFiles(input.files);
230
+ // Reset input so the same file can be selected again
231
+ input.value = '';
232
+ };
233
+ this.openFileDialog = (ev) => {
234
+ var _a;
235
+ ev === null || ev === void 0 ? void 0 : ev.preventDefault();
236
+ ev === null || ev === void 0 ? void 0 : ev.stopPropagation();
237
+ if (this.disabled)
238
+ return;
239
+ (_a = this.fileInput) === null || _a === void 0 ? void 0 : _a.click();
240
+ };
241
+ this.handleZoneMouseEnter = () => {
242
+ if (!this.disabled)
243
+ this.zoneHovered = true;
244
+ };
245
+ this.handleZoneMouseLeave = () => {
246
+ this.zoneHovered = false;
247
+ };
248
+ this.handleZoneKeyDown = (event) => {
249
+ if (this.disabled)
250
+ return;
251
+ if (event.key === ' ' || event.key === 'Enter') {
252
+ event.preventDefault();
253
+ this.openFileDialog();
254
+ }
255
+ };
256
+ this.handleFocus = (event) => {
257
+ this.bcmFocus.emit(event);
258
+ };
259
+ this.handleBlur = (event) => {
260
+ this.bcmBlur.emit(event);
261
+ };
262
+ this.name = 'file';
263
+ this.label = '';
264
+ this.caption = '';
265
+ this.noCaption = false;
266
+ this.multiple = false;
267
+ this.accept = '';
268
+ this.maxSize = 2;
269
+ this.required = false;
270
+ this.disabled = false;
271
+ this.size = 'medium';
272
+ this.position = 'vertical';
273
+ this.buttonLabel = undefined;
274
+ this.showFileList = true;
275
+ this.fullWidth = false;
276
+ this.uploadUrl = undefined;
277
+ this.maxFileCount = undefined;
278
+ this.customErrorMessages = undefined;
279
+ this.value = null;
280
+ this.captionError = undefined;
281
+ this.captionType = undefined;
282
+ this.files = [];
283
+ this.dragActive = false;
284
+ this.zoneHovered = false;
285
+ this.maxSizeError = false;
286
+ this.typeError = false;
287
+ this.maxFileCountError = false;
288
+ }
289
+ componentWillLoad() {
290
+ this.internalMaxSizeInBytes = this.maxSize * 1024 * 1024;
291
+ if (!this.host.hasAttribute('position') && this.size === 'small') {
292
+ this.position = 'horizontal';
293
+ }
294
+ }
295
+ get isButtonMode() {
296
+ return this.position === 'button';
297
+ }
298
+ get zoneError() {
299
+ return this.captionType === 'error' && !!this.captionError;
300
+ }
301
+ getStyleProps() {
302
+ return {
303
+ size: this.size,
304
+ position: this.position,
305
+ disabled: this.disabled,
306
+ zoneHovered: this.zoneHovered,
307
+ dragActive: this.dragActive,
308
+ zoneError: this.zoneError,
309
+ fullWidth: this.fullWidth,
310
+ };
311
+ }
312
+ disconnectedCallback() {
313
+ // Clear interval when component is removed from the DOM
314
+ if (this.uploadTimer) {
315
+ window.clearInterval(this.uploadTimer);
316
+ this.uploadTimer = undefined;
317
+ }
318
+ }
319
+ handleMaxSizeChange() {
320
+ this.internalMaxSizeInBytes = this.maxSize * 1024 * 1024;
321
+ }
322
+ /**
323
+ * Normalize and check a file against the `accept` attribute.
324
+ */
325
+ isFileAccepted(file) {
326
+ if (!this.accept)
327
+ return true;
328
+ const extension = '.' + (file.name.split('.').pop() || '').toLowerCase();
329
+ const accepted = this.accept
330
+ .toLowerCase()
331
+ .split(',')
332
+ .map(x => x.trim())
333
+ .filter(Boolean); // e.g. ['.pdf', '.jpg', '.png']
334
+ return accepted.includes(extension);
335
+ }
336
+ emitChange() {
337
+ const fileObjects = this.files.map(f => f.file);
338
+ this.value = fileObjects.length > 0 ? fileObjects : null;
339
+ this.bcmFileChange.emit(fileObjects);
340
+ this.bcmChange.emit(this.value);
341
+ }
342
+ normalizeSetDataToItems(data) {
343
+ const input = Array.isArray(data) ? data : [data];
344
+ return input
345
+ .filter(item => item instanceof File)
346
+ .map((file) => ({
347
+ id: generate.Generate.UID(),
348
+ file,
349
+ status: this.showFileList ? 'uploading' : 'uploaded',
350
+ progress: this.showFileList ? 0 : undefined,
351
+ }));
352
+ }
353
+ async get() {
354
+ return this.value;
355
+ }
356
+ async set(data) {
357
+ if (this.uploadTimer) {
358
+ window.clearInterval(this.uploadTimer);
359
+ this.uploadTimer = undefined;
360
+ }
361
+ const items = this.normalizeSetDataToItems(data);
362
+ if (items.length > 0) {
363
+ this.files = this.multiple ? items : [items[0]];
364
+ this.maxSizeError = false;
365
+ this.typeError = false;
366
+ this.maxFileCountError = false;
367
+ this.emitChange();
368
+ if (this.showFileList) {
369
+ this.startFakeUpload();
370
+ }
371
+ return;
372
+ }
373
+ // Backward-compatible fallback for non-File payloads
374
+ this.value = data;
375
+ this.bcmChange.emit(this.value);
376
+ }
377
+ async setClear() {
378
+ this.files = [];
379
+ this.maxSizeError = false;
380
+ this.typeError = false;
381
+ this.maxFileCountError = false;
382
+ this.emitChange();
383
+ return new Promise(resolve => setTimeout(() => {
384
+ this.resetCaption();
385
+ resolve(undefined);
386
+ }, 10));
387
+ }
388
+ async resetCaption() {
389
+ return new Promise(resolve => setTimeout(() => {
390
+ this.captionError = null;
391
+ this.captionType = null;
392
+ this.maxSizeError = false;
393
+ this.typeError = false;
394
+ this.maxFileCountError = false;
395
+ resolve(undefined);
396
+ }, 10));
397
+ }
398
+ /**
399
+ * Simulate upload progress. Replace with real upload logic if needed.
400
+ */
401
+ startFakeUpload() {
402
+ if (this.uploadTimer) {
403
+ window.clearInterval(this.uploadTimer);
404
+ }
405
+ this.uploadTimer = window.setInterval(() => {
406
+ let anyUploading = false;
407
+ this.files = this.files.map(item => {
408
+ var _a;
409
+ if (item.status !== 'uploading')
410
+ return item;
411
+ anyUploading = true;
412
+ const current = (_a = item.progress) !== null && _a !== void 0 ? _a : 0;
413
+ const next = Math.min(current + 15, 100);
414
+ if (next >= 100) {
415
+ return Object.assign(Object.assign({}, item), { status: 'uploaded', progress: undefined });
416
+ }
417
+ return Object.assign(Object.assign({}, item), { progress: next });
418
+ });
419
+ if (!anyUploading && this.uploadTimer) {
420
+ window.clearInterval(this.uploadTimer);
421
+ this.uploadTimer = undefined;
422
+ this.emitChange();
423
+ }
424
+ }, 300);
425
+ }
426
+ /**
427
+ * Add files from input or drop.
428
+ */
429
+ addFiles(fileList) {
430
+ if (!fileList || this.disabled)
431
+ return;
432
+ const newItems = [];
433
+ let hasSizeError = false;
434
+ let hasTypeError = false;
435
+ Array.from(fileList).forEach(file => {
436
+ if (!this.isFileAccepted(file)) {
437
+ hasTypeError = true;
438
+ return;
439
+ }
440
+ if (file.size > this.internalMaxSizeInBytes) {
441
+ hasSizeError = true;
442
+ return;
443
+ }
444
+ newItems.push({
445
+ id: generate.Generate.UID(),
446
+ file,
447
+ status: this.showFileList ? 'uploading' : 'uploaded',
448
+ progress: this.showFileList ? 0 : undefined,
449
+ });
450
+ });
451
+ this.maxSizeError = hasSizeError;
452
+ this.typeError = hasTypeError;
453
+ this.maxFileCountError = false;
454
+ // If there are no valid files, just update validity and exit.
455
+ if (!newItems.length) {
456
+ this.emitChange();
457
+ return;
458
+ }
459
+ let merged;
460
+ if (this.multiple) {
461
+ if (typeof this.maxFileCount === 'number') {
462
+ const remaining = this.maxFileCount - this.files.length;
463
+ if (remaining <= 0) {
464
+ this.maxFileCountError = true;
465
+ this.emitChange();
466
+ return;
467
+ }
468
+ const acceptedNew = newItems.slice(0, Math.max(0, remaining));
469
+ if (acceptedNew.length < newItems.length) {
470
+ this.maxFileCountError = true;
471
+ }
472
+ merged = [...this.files, ...acceptedNew];
473
+ }
474
+ else {
475
+ merged = [...this.files, ...newItems];
476
+ }
477
+ }
478
+ else {
479
+ // single file mode → only take first new item
480
+ merged = [newItems[0]];
481
+ }
482
+ this.files = merged;
483
+ this.emitChange();
484
+ // Only fake upload for now (skip when file list UI is hidden).
485
+ if (this.showFileList) {
486
+ this.startFakeUpload();
487
+ }
488
+ }
489
+ removeFile(item) {
490
+ this.files = this.files.filter(f => f.id !== item.id);
491
+ this.bcmFileRemoved.emit(item);
492
+ this.emitChange();
493
+ }
494
+ cancelUpload(item) {
495
+ this.files = this.files.filter(f => f.id !== item.id);
496
+ this.bcmUploadCanceled.emit(item);
497
+ this.emitChange();
498
+ }
499
+ handleDrop(ev) {
500
+ var _a;
501
+ ev.preventDefault();
502
+ this.dragActive = false;
503
+ if (this.disabled || this.isButtonMode)
504
+ return;
505
+ const files = ((_a = ev.dataTransfer) === null || _a === void 0 ? void 0 : _a.files) || null;
506
+ if (!files || files.length === 0)
507
+ return;
508
+ const first = files.item(0);
509
+ if (!first || !this.isFileAccepted(first)) {
510
+ this.typeError = true;
511
+ return;
512
+ }
513
+ this.addFiles(files);
514
+ }
515
+ handleDragOver(ev) {
516
+ ev.preventDefault();
517
+ if (this.disabled || this.isButtonMode)
518
+ return;
519
+ this.dragActive = true;
520
+ }
521
+ handleDragLeave(ev) {
522
+ ev.preventDefault();
523
+ this.dragActive = false;
524
+ }
525
+ async setFocus(options) {
526
+ var _a, _b;
527
+ if (this.isButtonMode) {
528
+ (_a = this.uploadButtonRef) === null || _a === void 0 ? void 0 : _a.focus(options);
529
+ return;
530
+ }
531
+ (_b = this.uploadZoneRef) === null || _b === void 0 ? void 0 : _b.focus(options);
532
+ }
533
+ getMaxSizeLabel() {
534
+ const maxMb = Math.round(this.internalMaxSizeInBytes / (1024 * 1024));
535
+ return `Maximum size ${maxMb}MB`;
536
+ }
537
+ renderErrors() {
538
+ var _a, _b, _c;
539
+ const { errorArea, errorIcon, errorClose } = uploadClasses(this.getStyleProps());
540
+ const maxSizeMsg = ((_a = this.customErrorMessages) === null || _a === void 0 ? void 0 : _a.maxSize) ||
541
+ `The file size exceeds the limit of ${Math.round(this.internalMaxSizeInBytes / (1024 * 1024))} MB.`;
542
+ const typeMsg = ((_b = this.customErrorMessages) === null || _b === void 0 ? void 0 : _b.type) ||
543
+ 'This file type is not supported.';
544
+ const maxFileCountMsg = ((_c = this.customErrorMessages) === null || _c === void 0 ? void 0 : _c.maxFileCount) ||
545
+ 'You have reached the maximum number of files.';
546
+ return (index$1.h("div", { class: "tw-w-full tw-space-y-2" }, this.maxSizeError && (index$1.h("div", { class: errorArea() }, index$1.h("div", { class: errorIcon() }, index$1.h("i", { class: "fa-solid fa-circle-exclamation" })), index$1.h("span", { class: "tw-flex-1" }, maxSizeMsg), index$1.h("div", { class: errorClose(), onClick: () => (this.maxSizeError = false) }, index$1.h("i", { class: "fa-solid fa-xmark" })))), this.typeError && (index$1.h("div", { class: errorArea() }, index$1.h("div", { class: errorIcon() }, index$1.h("i", { class: "fa-solid fa-circle-exclamation" })), index$1.h("span", { class: "tw-flex-1" }, typeMsg), index$1.h("div", { class: errorClose(), onClick: () => (this.typeError = false) }, index$1.h("i", { class: "fa-solid fa-xmark" })))), this.maxFileCountError && (index$1.h("div", { class: errorArea() }, index$1.h("div", { class: errorIcon() }, index$1.h("i", { class: "fa-solid fa-circle-exclamation" })), index$1.h("span", { class: "tw-flex-1" }, maxFileCountMsg), index$1.h("div", { class: errorClose(), onClick: () => (this.maxFileCountError = false) }, index$1.h("i", { class: "fa-solid fa-xmark" }))))));
547
+ }
548
+ renderUploadZone() {
549
+ const { zone, iconContainer, iconSizeClass, zoneTextWrapper, zoneTextMain, zoneTextSub, zoneLink, } = uploadClasses(this.getStyleProps());
550
+ return (index$1.h("div", { ref: el => (this.uploadZoneRef = el), tabindex: this.disabled ? undefined : 0, part: "upload-zone", class: zone(), role: "button", "aria-disabled": this.disabled ? 'true' : 'false', "aria-labelledby": this.label ? this.labelId : undefined, "aria-label": this.label || 'File upload', onClick: this.openFileDialog, onKeyDown: this.handleZoneKeyDown, onFocus: this.handleFocus, onBlur: this.handleBlur, onMouseEnter: this.handleZoneMouseEnter, onMouseLeave: this.handleZoneMouseLeave, onDragOver: ev => this.handleDragOver(ev), onDragLeave: ev => this.handleDragLeave(ev), onDrop: ev => this.handleDrop(ev) }, index$1.h("div", { class: iconContainer() }, index$1.h("i", { class: `fa-solid fa-cloud-arrow-up ${iconSizeClass()}`, "aria-hidden": "true" })), index$1.h("div", { class: zoneTextWrapper() }, index$1.h("div", { class: zoneTextMain() }, "Drag and drop your file here ", index$1.h("span", { class: "tw-inline-block" }, "or", ' ', index$1.h("span", { class: zoneLink(), role: "button", tabindex: -1, "aria-label": "Choose file", onClick: e => this.openFileDialog(e) }, "Browse files"))), index$1.h("div", { class: zoneTextSub() }, this.getMaxSizeLabel()))));
551
+ }
552
+ renderUploadButton() {
553
+ const { triggerWrap } = uploadClasses(this.getStyleProps());
554
+ const label = this.buttonLabel || 'Upload';
555
+ return (index$1.h("div", { class: triggerWrap(), part: "upload-trigger" }, index$1.h("bcm-button", { ref: el => (this.uploadButtonRef = el), variant: "upload", size: this.size, disabled: this.disabled, onFocus: this.handleFocus, onBlur: this.handleBlur, "onBcm-click": (e) => this.openFileDialog(e) }, label)));
556
+ }
557
+ renderHiddenInput() {
558
+ return (index$1.h("input", { ref: el => (this.fileInput = el), id: this.inputId, type: "file", hidden: true, accept: this.accept, multiple: this.multiple, disabled: this.disabled, onChange: this.onFileInputChange }));
559
+ }
560
+ renderFileRow(item) {
561
+ var _a, _b;
562
+ const { percent, iconBtn, fileRow, fileRowHeader, fileIcon, fileTitle, progressWrapper, progressTrack, progressBar, } = uploadClasses(this.getStyleProps());
563
+ const isUploading = (item === null || item === void 0 ? void 0 : item.status) === 'uploading';
564
+ return (index$1.h("div", { part: "file-row", class: fileRow(), title: (_a = item === null || item === void 0 ? void 0 : item.file) === null || _a === void 0 ? void 0 : _a.name }, index$1.h("div", { class: fileRowHeader() }, index$1.h("i", { class: `fa-regular fa-file ${fileIcon()}` }), index$1.h("span", { class: fileTitle() }, (_b = item === null || item === void 0 ? void 0 : item.file) === null || _b === void 0 ? void 0 : _b.name), index$1.h("button", { type: "button", part: isUploading ? 'cancel-btn' : 'remove-btn', class: iconBtn(), onClick: () => isUploading ? this.cancelUpload(item) : this.removeFile(item), title: isUploading ? 'Cancel' : 'Remove' }, index$1.h("i", { class: "fa-regular fa-trash" }))), this.showFileList && isUploading && (index$1.h("div", { class: progressWrapper() }, index$1.h("div", { class: progressTrack() }, index$1.h("div", { class: progressBar(), style: { width: `${item.progress || 0}%` } })), index$1.h("span", { class: percent() }, item.progress || 0, "%")))));
565
+ }
566
+ render() {
567
+ const { container, label, list, captionWrap } = uploadClasses(this.getStyleProps());
568
+ const hasCaptionText = typeof this.caption === 'string' ? this.caption.trim().length > 0 : !!this.caption;
569
+ const shouldShowCaption = !this.noCaption && (hasCaptionText || !!this.captionError);
570
+ return (index$1.h(index$1.Host, { tabindex: "-1" }, index$1.h("div", { class: container() }, this.label && (index$1.h("label", { id: this.labelId, htmlFor: this.inputId, part: "label", class: label() }, this.label)), this.isButtonMode ? this.renderUploadButton() : this.renderUploadZone(), this.renderHiddenInput(), this.renderErrors(), shouldShowCaption && (index$1.h("div", { class: captionWrap(), part: "caption" }, index$1.h(captionTemplate.CaptionTemplate, { noCaption: false, captionType: this.captionType, captionError: this.captionError, caption: this.caption, size: this.size === 'small' ? 'medium' : 'large' }))), this.showFileList && this.files.length > 0 && (index$1.h("div", { part: "file-list", class: list() }, this.files.map(item => this.renderFileRow(item)))))));
571
+ }
572
+ get host() { return index$1.getElement(this); }
573
+ static get watchers() { return {
574
+ "maxSize": ["handleMaxSizeChange"]
575
+ }; }
576
+ };
577
+
578
+ exports.bcm_file_upload = BcmFileUpload;
@@ -8,10 +8,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
8
8
 
9
9
  const index = require('./index-c591ecec.js');
10
10
  const isLoadDecorator = require('./is-load-decorator-15036f37.js');
11
- const generate = require('./generate-554f54dc.js');
11
+ const generate = require('./generate-9d1bf6b3.js');
12
12
  const stringHelper = require('./string-helper-9cdfb273.js');
13
13
  const bcm = require('./bcm-1d1fcf21.js');
14
- require('./package-8445ccd4.js');
14
+ require('./package-6de220be.js');
15
15
  require('./colors-250d0982.js');
16
16
  require('./_commonjsHelpers-ed84c3ca.js');
17
17
 
@@ -36,6 +36,7 @@ const BcmFormComponents = [
36
36
  'BCM-CHIP-GROUP',
37
37
  'BCM-INPUT-DROPDOWN',
38
38
  'BCM-NUMBER-INPUT',
39
+ 'BCM-FILE-UPLOAD',
39
40
  //... to be added to v3
40
41
  ];
41
42
 
@@ -9,12 +9,12 @@ Object.defineProperty(exports, '__esModule', { value: true });
9
9
  const index = require('./index-c591ecec.js');
10
10
  const index$1 = require('./index-95ae50d0.js');
11
11
  const isLoadDecorator = require('./is-load-decorator-15036f37.js');
12
- const generate = require('./generate-554f54dc.js');
12
+ const generate = require('./generate-9d1bf6b3.js');
13
13
  const bcm = require('./bcm-1d1fcf21.js');
14
14
  const captionTemplate = require('./caption-template-f8a78504.js');
15
15
  const input_style = require('./input.style-bee84fb0.js');
16
16
  require('./_commonjsHelpers-ed84c3ca.js');
17
- require('./package-8445ccd4.js');
17
+ require('./package-6de220be.js');
18
18
  require('./colors-250d0982.js');
19
19
  require('./index-5279dea2.js');
20
20
 
@@ -7,9 +7,9 @@
7
7
  Object.defineProperty(exports, '__esModule', { value: true });
8
8
 
9
9
  const index = require('./index-c591ecec.js');
10
- const generate = require('./generate-554f54dc.js');
10
+ const generate = require('./generate-9d1bf6b3.js');
11
11
  const index$1 = require('./index-95ae50d0.js');
12
- require('./package-8445ccd4.js');
12
+ require('./package-6de220be.js');
13
13
  require('./colors-250d0982.js');
14
14
  require('./_commonjsHelpers-ed84c3ca.js');
15
15
 
@@ -9,10 +9,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
9
9
  const index$1 = require('./index-c591ecec.js');
10
10
  require('./color-helper-dc98a2ca.js');
11
11
  require('./datetime-helper-eaf4fadb.js');
12
- const generate = require('./generate-554f54dc.js');
13
- require('./number-helper-677e9c02.js');
12
+ const generate = require('./generate-9d1bf6b3.js');
13
+ require('./number-helper-ae28b255.js');
14
14
  require('./string-helper-9cdfb273.js');
15
- require('./validators-92f2f1ef.js');
15
+ require('./validators-3381bee2.js');
16
16
  require('./element-dragger-a8562f82.js');
17
17
  const bcm = require('./bcm-1d1fcf21.js');
18
18
  const captionTemplate = require('./caption-template-f8a78504.js');
@@ -24,7 +24,7 @@ require('./colors-56282b00.js');
24
24
  require('./utils-fc077139.js');
25
25
  require('./colors-250d0982.js');
26
26
  require('./_commonjsHelpers-ed84c3ca.js');
27
- require('./package-8445ccd4.js');
27
+ require('./package-6de220be.js');
28
28
 
29
29
  const inputDropdownStyle = index.ce({
30
30
  slots: {
@@ -9,10 +9,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
9
9
  const index = require('./index-c591ecec.js');
10
10
  require('./color-helper-dc98a2ca.js');
11
11
  require('./datetime-helper-eaf4fadb.js');
12
- const generate = require('./generate-554f54dc.js');
13
- require('./number-helper-677e9c02.js');
12
+ const generate = require('./generate-9d1bf6b3.js');
13
+ require('./number-helper-ae28b255.js');
14
14
  require('./string-helper-9cdfb273.js');
15
- require('./validators-92f2f1ef.js');
15
+ require('./validators-3381bee2.js');
16
16
  require('./element-dragger-a8562f82.js');
17
17
  require('./bcm-1d1fcf21.js');
18
18
  const index$1 = require('./index-95ae50d0.js');
@@ -20,7 +20,7 @@ require('./colors-56282b00.js');
20
20
  require('./utils-fc077139.js');
21
21
  require('./colors-250d0982.js');
22
22
  require('./_commonjsHelpers-ed84c3ca.js');
23
- require('./package-8445ccd4.js');
23
+ require('./package-6de220be.js');
24
24
 
25
25
  const BcmModal2Footer = class {
26
26
  constructor(hostRef) {