@irontec/ivoz-ui 1.4.2 → 1.4.4
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/components/List/Content/ListContentValue.js +6 -0
- package/components/List/DownloadFile.d.ts +7 -0
- package/components/List/DownloadFile.js +31 -0
- package/components/List/DownloadFile.styles.d.ts +21 -0
- package/components/List/DownloadFile.styles.js +19 -0
- package/package.json +1 -1
- package/services/api/ParsedApiSpecInterface.d.ts +1 -0
- package/services/form/Field/TextField/TextField.js +15 -1
|
@@ -4,11 +4,14 @@ import { matchRoutes } from 'react-router-dom';
|
|
|
4
4
|
import { useStoreState } from 'store';
|
|
5
5
|
import { isPropertyFk, } from '../../../services/api/ParsedApiSpecInterface';
|
|
6
6
|
import { StyledCheckBoxIcon, StyledCheckBoxOutlineBlankIcon, StyledTableRowFkLink, } from './Table/ContentTable.styles';
|
|
7
|
+
import DownloadFile from '../DownloadFile';
|
|
7
8
|
const ListContentValue = (props) => {
|
|
8
9
|
const { column, columnName, row, entityService } = props;
|
|
9
10
|
const routes = useStoreState((state) => state.routes.routes);
|
|
10
11
|
const ListDecorator = entityService.getListDecorator();
|
|
11
12
|
const customComponent = column.component;
|
|
13
|
+
const isDownloadable = column.downloadable;
|
|
14
|
+
const isFileType = column.type === 'file';
|
|
12
15
|
const isFk = isPropertyFk(column);
|
|
13
16
|
const loadingFk = isFk &&
|
|
14
17
|
column.type !== 'array' &&
|
|
@@ -57,6 +60,9 @@ const ListContentValue = (props) => {
|
|
|
57
60
|
else {
|
|
58
61
|
response = _jsx(ListDecorator, { field: columnName, row: row, property: column });
|
|
59
62
|
}
|
|
63
|
+
if (isDownloadable && isFileType) {
|
|
64
|
+
response = (_jsx(DownloadFile, { row: row, path: entityService.getEntity().path, fileType: columnName }));
|
|
65
|
+
}
|
|
60
66
|
const prefix = (column === null || column === void 0 ? void 0 : column.prefix) || '';
|
|
61
67
|
return (_jsxs(Box, Object.assign({ component: 'span', className: 'cell' }, { children: [prefix, response] })));
|
|
62
68
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { useStoreActions } from 'store';
|
|
12
|
+
import { StyledPdfIcon, StyledFileName } from './DownloadFile.styles';
|
|
13
|
+
import { saveAs } from 'file-saver';
|
|
14
|
+
export default function DownloadFile(props) {
|
|
15
|
+
const { row, path, fileType } = props;
|
|
16
|
+
const apiDownload = useStoreActions((actions) => {
|
|
17
|
+
return actions.api.download;
|
|
18
|
+
});
|
|
19
|
+
const download = () => {
|
|
20
|
+
apiDownload({
|
|
21
|
+
path: `${path}/${row.id}/${fileType}`,
|
|
22
|
+
params: {},
|
|
23
|
+
successCallback: (data, headers) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
const fileName = (_b = (_a = headers['content-disposition']) === null || _a === void 0 ? void 0 : _a.split('filename=')) === null || _b === void 0 ? void 0 : _b.pop();
|
|
26
|
+
saveAs(data, fileName || 'download');
|
|
27
|
+
}),
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
return (_jsxs(_Fragment, { children: [_jsx(StyledPdfIcon, { onClick: download }), _jsx(StyledFileName, { children: row[fileType].baseName })] }));
|
|
31
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const StyledPdfIcon: import("@emotion/styled").StyledComponent<{
|
|
3
|
+
children?: import("react").ReactNode;
|
|
4
|
+
classes?: Partial<import("@mui/material").SvgIconClasses> | undefined;
|
|
5
|
+
color?: "inherit" | "disabled" | "error" | "action" | "success" | "warning" | "info" | "primary" | "secondary" | undefined;
|
|
6
|
+
fontSize?: "small" | "inherit" | "large" | "medium" | undefined;
|
|
7
|
+
htmlColor?: string | undefined;
|
|
8
|
+
inheritViewBox?: boolean | undefined;
|
|
9
|
+
shapeRendering?: string | undefined;
|
|
10
|
+
sx?: import("@mui/system").SxProps<import("@mui/material").Theme> | undefined;
|
|
11
|
+
titleAccess?: string | undefined;
|
|
12
|
+
viewBox?: string | undefined;
|
|
13
|
+
} & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").SVGProps<SVGSVGElement>, "string" | "className" | "id" | "lang" | "style" | "tabIndex" | "role" | "color" | "children" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "clipPath" | "filter" | "mask" | "path" | "cursor" | "direction" | "display" | "fontFamily" | "fontSize" | "fontSizeAdjust" | "fontStretch" | "fontStyle" | "fontVariant" | "fontWeight" | "height" | "imageRendering" | "letterSpacing" | "opacity" | "order" | "paintOrder" | "pointerEvents" | "rotate" | "scale" | "textRendering" | "transform" | "unicodeBidi" | "visibility" | "width" | "wordSpacing" | "writingMode" | "offset" | "overflow" | "textDecoration" | "azimuth" | "clip" | "alignmentBaseline" | "baselineShift" | "clipRule" | "colorInterpolation" | "colorRendering" | "dominantBaseline" | "fill" | "fillOpacity" | "fillRule" | "floodColor" | "floodOpacity" | "glyphOrientationVertical" | "lightingColor" | "markerEnd" | "markerMid" | "markerStart" | "shapeRendering" | "stopColor" | "stopOpacity" | "stroke" | "strokeDasharray" | "strokeDashoffset" | "strokeLinecap" | "strokeLinejoin" | "strokeMiterlimit" | "strokeOpacity" | "strokeWidth" | "textAnchor" | "vectorEffect" | "name" | "key" | "max" | "media" | "method" | "min" | "target" | "type" | "crossOrigin" | "accentHeight" | "accumulate" | "additive" | "allowReorder" | "alphabetic" | "amplitude" | "arabicForm" | "ascent" | "attributeName" | "attributeType" | "autoReverse" | "baseFrequency" | "baseProfile" | "bbox" | "begin" | "bias" | "by" | "calcMode" | "capHeight" | "clipPathUnits" | "colorInterpolationFilters" | "colorProfile" | "contentScriptType" | "contentStyleType" | "cx" | "cy" | "d" | "decelerate" | "descent" | "diffuseConstant" | "divisor" | "dur" | "dx" | "dy" | "edgeMode" | "elevation" | "enableBackground" | "end" | "exponent" | "externalResourcesRequired" | "filterRes" | "filterUnits" | "focusable" | "format" | "fr" | "from" | "fx" | "fy" | "g1" | "g2" | "glyphName" | "glyphOrientationHorizontal" | "glyphRef" | "gradientTransform" | "gradientUnits" | "hanging" | "horizAdvX" | "horizOriginX" | "href" | "ideographic" | "in2" | "in" | "intercept" | "k1" | "k2" | "k3" | "k4" | "k" | "kernelMatrix" | "kernelUnitLength" | "kerning" | "keyPoints" | "keySplines" | "keyTimes" | "lengthAdjust" | "limitingConeAngle" | "local" | "markerHeight" | "markerUnits" | "markerWidth" | "maskContentUnits" | "maskUnits" | "mathematical" | "mode" | "numOctaves" | "operator" | "orient" | "orientation" | "origin" | "overlinePosition" | "overlineThickness" | "panose1" | "pathLength" | "patternContentUnits" | "patternTransform" | "patternUnits" | "points" | "pointsAtX" | "pointsAtY" | "pointsAtZ" | "preserveAlpha" | "preserveAspectRatio" | "primitiveUnits" | "r" | "radius" | "refX" | "refY" | "renderingIntent" | "repeatCount" | "repeatDur" | "requiredExtensions" | "requiredFeatures" | "restart" | "result" | "rx" | "ry" | "seed" | "slope" | "spacing" | "specularConstant" | "specularExponent" | "speed" | "spreadMethod" | "startOffset" | "stdDeviation" | "stemh" | "stemv" | "stitchTiles" | "strikethroughPosition" | "strikethroughThickness" | "surfaceScale" | "systemLanguage" | "tableValues" | "targetX" | "targetY" | "textLength" | "to" | "u1" | "u2" | "underlinePosition" | "underlineThickness" | "unicode" | "unicodeRange" | "unitsPerEm" | "vAlphabetic" | "values" | "version" | "vertAdvY" | "vertOriginX" | "vertOriginY" | "vHanging" | "vIdeographic" | "viewBox" | "viewTarget" | "vMathematical" | "widths" | "x1" | "x2" | "x" | "xChannelSelector" | "xHeight" | "xlinkActuate" | "xlinkArcrole" | "xlinkHref" | "xlinkRole" | "xlinkShow" | "xlinkTitle" | "xlinkType" | "xmlBase" | "xmlLang" | "xmlns" | "xmlnsXlink" | "xmlSpace" | "y1" | "y2" | "y" | "yChannelSelector" | "z" | "zoomAndPan"> & {
|
|
14
|
+
ref?: ((instance: SVGSVGElement | null) => void) | import("react").RefObject<SVGSVGElement> | null | undefined;
|
|
15
|
+
}, "color" | "children" | "fontSize" | "shapeRendering" | keyof import("@mui/material/OverridableComponent").CommonProps | "sx" | "viewBox" | "htmlColor" | "inheritViewBox" | "titleAccess"> & {
|
|
16
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
17
|
+
}, {}, {}>;
|
|
18
|
+
export declare const StyledFileName: import("@emotion/styled").StyledComponent<{
|
|
19
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
20
|
+
as?: import("react").ElementType<any> | undefined;
|
|
21
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import styled from '@emotion/styled';
|
|
2
|
+
import DownloadIcon from '@mui/icons-material/Download';
|
|
3
|
+
export const StyledPdfIcon = styled(DownloadIcon)(() => {
|
|
4
|
+
return {
|
|
5
|
+
color: '#5b5b5b',
|
|
6
|
+
verticalAlign: 'bottom',
|
|
7
|
+
fontSize: '1.3em',
|
|
8
|
+
cursor: 'pointer',
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
export const StyledFileName = styled.span(() => {
|
|
12
|
+
return {
|
|
13
|
+
whiteSpace: 'nowrap',
|
|
14
|
+
overflow: 'hidden',
|
|
15
|
+
textOverflow: 'ellipsis',
|
|
16
|
+
maxWidth: '60px',
|
|
17
|
+
display: 'inline-flex',
|
|
18
|
+
};
|
|
19
|
+
});
|
package/package.json
CHANGED
|
@@ -12,6 +12,10 @@ export const TextField = (props) => {
|
|
|
12
12
|
}
|
|
13
13
|
const labelId = `${name}-label`;
|
|
14
14
|
const maxRows = multiline ? 6 : undefined;
|
|
15
|
+
const fixDateTime = (value) => {
|
|
16
|
+
const haveMissingSeconds = value.length === 16;
|
|
17
|
+
return haveMissingSeconds ? value.concat(':00') : value;
|
|
18
|
+
};
|
|
15
19
|
const passThroughProps = {};
|
|
16
20
|
if (onKeyDown) {
|
|
17
21
|
passThroughProps.onKeyDown = onKeyDown;
|
|
@@ -19,5 +23,15 @@ export const TextField = (props) => {
|
|
|
19
23
|
if (onClick) {
|
|
20
24
|
passThroughProps.onClick = onClick;
|
|
21
25
|
}
|
|
22
|
-
|
|
26
|
+
passThroughProps.onChange = (event) => {
|
|
27
|
+
const { target } = event;
|
|
28
|
+
if (type === 'datetime-local') {
|
|
29
|
+
const fixedDate = fixDateTime(target.value);
|
|
30
|
+
event.target = Object.assign(Object.assign({}, target), { value: fixedDate });
|
|
31
|
+
}
|
|
32
|
+
if (onChange) {
|
|
33
|
+
onChange(event);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return (_jsxs(FormControl, Object.assign({ variant: 'standard', fullWidth: true, error: error, className: className }, { children: [label && (_jsxs("label", Object.assign({ htmlFor: name, id: labelId }, { children: [label, required && '*', helperText && (_jsx(StyledHelpTextTooltip, Object.assign({ title: helperText, placement: 'top', arrow: true, className: 'help-tooltip' }, { children: _jsx(HelpOutlineIcon, {}) })))] }))), _jsx(OutlinedInput, Object.assign({}, passThroughProps, { ref: InputProps === null || InputProps === void 0 ? void 0 : InputProps.ref, name: name, type: type, size: size, multiline: multiline, maxRows: maxRows, placeholder: placeholder, defaultValue: defaultValue, value: value, disabled: disabled, onBlur: onBlur, error: error, className: 'input-field', margin: margin, inputProps: inputProps, startAdornment: InputProps === null || InputProps === void 0 ? void 0 : InputProps.startAdornment, endAdornment: InputProps === null || InputProps === void 0 ? void 0 : InputProps.endAdornment, inputRef: inputRef })), error && errorMsg && (_jsx(FormHelperText, Object.assign({ className: 'helper-error' }, { children: errorMsg })))] })));
|
|
23
37
|
};
|