@app-studio/web 0.9.28 → 0.9.30

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.
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ interface AttachmentPreviewProps {
3
+ files: Array<{
4
+ name: string;
5
+ size: number;
6
+ type: string;
7
+ url?: string;
8
+ }>;
9
+ onRemove?: (index: number) => void;
10
+ maxHeight?: string;
11
+ views?: {
12
+ container?: any;
13
+ item?: any;
14
+ name?: any;
15
+ removeButton?: any;
16
+ };
17
+ }
18
+ export declare const AttachmentPreview: React.FC<AttachmentPreviewProps>;
19
+ export {};
@@ -14,3 +14,4 @@ export { FormikComboBox } from './Formik.ComboBox';
14
14
  export { FormikSlider } from './Formik.Slider';
15
15
  export { FormikOTPInput } from './Formik.OTPInput';
16
16
  export { FormikUploader } from './Formik.Uploader';
17
+ export { AttachmentPreview } from './AttachmentPreview';
@@ -4057,13 +4057,13 @@ var UploadView = _ref => {
4057
4057
  textProps
4058
4058
  }), progress < 100 && (icon || /*#__PURE__*/React__default.createElement(UploadIcon, Object.assign({
4059
4059
  widthHeight: 32
4060
- }, iconProps))), !selectedFile && text && renderText({
4060
+ }, iconProps))), !isLoading && !selectedFile && text && renderText({
4061
4061
  text,
4062
4062
  textProps
4063
4063
  }), isLoading && renderProgress({
4064
4064
  progress,
4065
4065
  progressProps
4066
- }), errorMessage && renderError({
4066
+ }), !isLoading && errorMessage && renderError({
4067
4067
  errorMessage,
4068
4068
  errorMessageProps
4069
4069
  }), /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
@@ -17196,6 +17196,139 @@ var FormikUploader = _ref => {
17196
17196
  };
17197
17197
  FormikUploader.displayName = 'FormikUploader';
17198
17198
 
17199
+ var AttachmentPreview = _ref => {
17200
+ var {
17201
+ files,
17202
+ onRemove,
17203
+ maxHeight = '120px',
17204
+ views = {}
17205
+ } = _ref;
17206
+ if (files.length === 0) {
17207
+ return null;
17208
+ }
17209
+ var formatFileSize = React.useCallback(bytes => {
17210
+ if (bytes < 1024) return bytes + " B";
17211
+ if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + " KB";
17212
+ return (bytes / (1024 * 1024)).toFixed(1) + " MB";
17213
+ }, []);
17214
+ return /*#__PURE__*/React__default.createElement(appStudio.View, Object.assign({
17215
+ display: "flex",
17216
+ flexWrap: "wrap",
17217
+ gap: "6px",
17218
+ padding: "8px 0",
17219
+ maxHeight: maxHeight,
17220
+ overflowY: "auto"
17221
+ }, views == null ? void 0 : views.container), files.map((file, index) => {
17222
+ var previewUrl = file.url || '';
17223
+ var isImage = file.type.startsWith('image/');
17224
+ var isVideo = file.type.startsWith('video/');
17225
+ var isAudio = file.type.startsWith('audio/');
17226
+ return /*#__PURE__*/React__default.createElement(appStudio.Vertical, Object.assign({
17227
+ key: index,
17228
+ alignItems: "center",
17229
+ gap: "6px",
17230
+ padding: "4px 8px",
17231
+ borderRadius: "6px",
17232
+ backgroundColor: "color.gray.100",
17233
+ position: "relative",
17234
+ animate: {
17235
+ from: {
17236
+ opacity: 0,
17237
+ scale: 0.9
17238
+ },
17239
+ to: {
17240
+ opacity: 1,
17241
+ scale: 1
17242
+ }
17243
+ },
17244
+ animationDuration: 0.2
17245
+ }, views == null ? void 0 : views.item), /*#__PURE__*/React__default.createElement(HoverCard, null, /*#__PURE__*/React__default.createElement(HoverCard.Trigger, null, /*#__PURE__*/React__default.createElement(appStudio.View, {
17246
+ position: "relative"
17247
+ }, isImage && previewUrl && (/*#__PURE__*/React__default.createElement(appStudio.Image, {
17248
+ src: previewUrl,
17249
+ alt: file.name,
17250
+ width: "60px",
17251
+ height: "60px",
17252
+ objectFit: "cover",
17253
+ borderRadius: "4px"
17254
+ })), isVideo && previewUrl && (/*#__PURE__*/React__default.createElement(appStudio.View, {
17255
+ as: "video",
17256
+ src: previewUrl,
17257
+ alt: file.name,
17258
+ controls: false,
17259
+ muted: true,
17260
+ width: "60px",
17261
+ height: "60px",
17262
+ objectFit: "cover",
17263
+ borderRadius: "4px"
17264
+ })), isAudio && (/*#__PURE__*/React__default.createElement(appStudio.Center, {
17265
+ width: "60px",
17266
+ height: "60px",
17267
+ backgroundColor: "color.gray.200",
17268
+ borderRadius: "4px"
17269
+ }, /*#__PURE__*/React__default.createElement(AudioIcon, {
17270
+ widthHeight: 24,
17271
+ color: "color.black"
17272
+ }))), !isImage && !isVideo && !isAudio && (/*#__PURE__*/React__default.createElement(appStudio.Center, {
17273
+ width: "60px",
17274
+ height: "60px",
17275
+ backgroundColor: "color.gray.200",
17276
+ borderRadius: "4px"
17277
+ }, /*#__PURE__*/React__default.createElement(FileIcon, {
17278
+ widthHeight: 24,
17279
+ color: "color.black"
17280
+ }))), onRemove && (/*#__PURE__*/React__default.createElement(appStudio.Button, {
17281
+ position: "absolute",
17282
+ top: "-4px",
17283
+ right: "-4px",
17284
+ width: "20px",
17285
+ height: "20px",
17286
+ minWidth: "20px",
17287
+ minHeight: "20px",
17288
+ borderRadius: "50%",
17289
+ backgroundColor: "color.red.500",
17290
+ color: "white",
17291
+ fontSize: 14,
17292
+ fontWeight: "bold",
17293
+ padding: 0,
17294
+ display: "flex",
17295
+ alignItems: "center",
17296
+ justifyContent: "center",
17297
+ cursor: "pointer",
17298
+ border: "2px solid white",
17299
+ _hover: {
17300
+ backgroundColor: 'color.red.600'
17301
+ },
17302
+ onClick: e => {
17303
+ e.stopPropagation();
17304
+ onRemove(index);
17305
+ },
17306
+ "aria-label": "Remove " + file.name
17307
+ }, "\u00D7")))), /*#__PURE__*/React__default.createElement(HoverCard.Content, null, isImage && previewUrl && (/*#__PURE__*/React__default.createElement(appStudio.Image, {
17308
+ src: previewUrl,
17309
+ alt: file.name,
17310
+ maxWidth: "300px"
17311
+ })), isVideo && previewUrl && (/*#__PURE__*/React__default.createElement(appStudio.View, {
17312
+ as: "video",
17313
+ src: previewUrl,
17314
+ controls: true,
17315
+ maxWidth: "300px"
17316
+ })), isAudio && previewUrl && (/*#__PURE__*/React__default.createElement(appStudio.View, {
17317
+ as: "audio",
17318
+ src: previewUrl,
17319
+ controls: true,
17320
+ width: '100%'
17321
+ })), /*#__PURE__*/React__default.createElement(Text, Object.assign({
17322
+ marginTop: "4px",
17323
+ truncateText: true,
17324
+ textOverflow: "ellipsis",
17325
+ overflow: "hidden",
17326
+ width: '100%',
17327
+ fontSize: 12
17328
+ }, views == null ? void 0 : views.name), file.name, " (", formatFileSize(file.size), ")"))));
17329
+ }));
17330
+ };
17331
+
17199
17332
  var SliderComponent$1 = props => {
17200
17333
  // Get state and handlers from the custom hook
17201
17334
  var sliderState = useSliderState(props);
@@ -35675,6 +35808,7 @@ exports.Alert = Alert;
35675
35808
  exports.ArrowIcon = ArrowIcon;
35676
35809
  exports.AspectRatio = AspectRatio;
35677
35810
  exports.AttachmentIcon = AttachmentIcon;
35811
+ exports.AttachmentPreview = AttachmentPreview;
35678
35812
  exports.AudioIcon = AudioIcon;
35679
35813
  exports.AudioInput = AudioInput;
35680
35814
  exports.AudioWaveform = AudioWaveform;