@irontec/ivoz-ui 1.3.11 → 1.3.15

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.
@@ -27,8 +27,9 @@ const FastSearchField = (props, ref) => {
27
27
  const isFk = isPropertyFk(firstColumnSpec);
28
28
  const foreignEntities = useStoreState((state) => state.list.fkChoices);
29
29
  const fkChoices = foreignEntities[firstColumnName] || [];
30
- const [value, setValue] = useState((firstColumnCriteria === null || firstColumnCriteria === void 0 ? void 0 : firstColumnCriteria.value) || '');
31
30
  const isDatetime = !isFk && firstColumnSpec.format === 'date-time';
31
+ const initialValue = (firstColumnCriteria === null || firstColumnCriteria === void 0 ? void 0 : firstColumnCriteria.value) || '';
32
+ const [value, setValue] = useState(isDatetime ? initialValue.replace(' ', 'T') : initialValue);
32
33
  const triggerSearchIfChanged = () => {
33
34
  if (!firstColumnCriteria) {
34
35
  return;
@@ -37,7 +38,8 @@ const FastSearchField = (props, ref) => {
37
38
  return;
38
39
  }
39
40
  if (value !== '') {
40
- firstColumnCriteria.value = encodeURIComponent(value);
41
+ const val = isDatetime ? value.replace('T', ' ') : value;
42
+ firstColumnCriteria.value = encodeURIComponent(val);
41
43
  }
42
44
  let match = false;
43
45
  let matchIdx;
@@ -14,7 +14,8 @@ const ChildEntityLinks = (props) => {
14
14
  firstActionButtonNum = 1;
15
15
  }
16
16
  const childEntitiesCopy = [...childEntities];
17
- const visibleChildEntities = childEntitiesCopy.splice(0, 2 - firstActionButtonNum);
17
+ const visibleChildEntitiesSlice = childEntitiesCopy.length <= 2 ? 3 : 2;
18
+ const visibleChildEntities = childEntitiesCopy.splice(0, visibleChildEntitiesSlice - firstActionButtonNum);
18
19
  return (_jsxs(_Fragment, { children: [detail, edit, visibleChildEntities.map((routeMapItem, key) => {
19
20
  if (isActionItem(routeMapItem) &&
20
21
  isSingleRowActionItem(routeMapItem, routeMapItem.action)) {
@@ -2,10 +2,10 @@
2
2
  to: src/entities/<%= Name %>/<%= Name %>.tsx
3
3
  ---
4
4
  import AccountTreeIcon from '@mui/icons-material/AccountTree';
5
- import EntityInterface from '@irontec/ivoz-ui/entities/EntityInterface';
6
- import _ from '@irontec/ivoz-ui/services/translations/translate';
7
- import defaultEntityBehavior from '@irontec/ivoz-ui/entities/DefaultEntityBehavior';
8
- import { EntityValue } from '@irontec/ivoz-ui';
5
+ import EntityInterface from '@irontec-voip/ivoz-ui/entities/EntityInterface';
6
+ import _ from '@irontec-voip/ivoz-ui/services/translations/translate';
7
+ import defaultEntityBehavior from '@irontec-voip/ivoz-ui/entities/DefaultEntityBehavior';
8
+ import { EntityValue } from '@irontec-voip/ivoz-ui';
9
9
  import selectOptions from './SelectOptions';
10
10
  import { <%= Name %>Properties, <%= Name %>PropertyList } from './<%= Name %>Properties';
11
11
 
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  to: src/entities/<%= Name %>/<%= Name %>Properties.ts
3
3
  ---
4
- import { PropertySpec } from '@irontec/ivoz-ui/services/api/ParsedApiSpecInterface';
5
- import { EntityValue, EntityValues } from '@irontec/ivoz-ui/services/entity/EntityService';
4
+ import { PropertySpec } from '@irontec-voip/ivoz-ui/services/api/ParsedApiSpecInterface';
5
+ import { EntityValue, EntityValues } from '@irontec-voip/ivoz-ui/services/entity/EntityService';
6
6
 
7
7
  export type <%= Name %>PropertyList<T> = {
8
8
  <%- h.formattedEntityProperties(h.url(), Name)%>
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  to: src/entities/<%= Name %>/ForeignKeyGetter.tsx
3
3
  ---
4
- import { ForeignKeyGetterType } from '@irontec/ivoz-ui/entities/EntityInterface';
5
- import { autoSelectOptions } from '@irontec/ivoz-ui/entities/DefaultEntityBehavior';
4
+ import { ForeignKeyGetterType } from '@irontec-voip/ivoz-ui/entities/EntityInterface';
5
+ import { autoSelectOptions } from '@irontec-voip/ivoz-ui/entities/DefaultEntityBehavior';
6
6
  import { <%= Name %>PropertyList } from './<%= Name %>Properties';
7
7
 
8
8
  /** TODO remove this file unless you need to change default behaviour **/
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  to: src/entities/<%= Name %>/ForeignKeyResolver.tsx
3
3
  ---
4
- import { autoForeignKeyResolver } from '@irontec/ivoz-ui/entities/DefaultEntityBehavior';
5
- import { foreignKeyResolverType } from '@irontec/ivoz-ui/entities/EntityInterface';
4
+ import { autoForeignKeyResolver } from '@irontec-voip/ivoz-ui/entities/DefaultEntityBehavior';
5
+ import { foreignKeyResolverType } from '@irontec-voip/ivoz-ui/entities/EntityInterface';
6
6
  import { <%= Name %>PropertiesList } from './<%= Name %>Properties';
7
7
 
8
8
  /** TODO remove this file unless you need to change default behaviour **/
@@ -1,10 +1,10 @@
1
1
  ---
2
2
  to: src/entities/<%= Name %>/Form.tsx
3
3
  ---
4
- import useFkChoices from '@irontec/ivoz-ui/entities/data/useFkChoices';
5
- import defaultEntityBehavior, { EntityFormProps, FieldsetGroups } from '@irontec/ivoz-ui/entities/DefaultEntityBehavior';
6
- import _ from '@irontec/ivoz-ui/services/translations/translate';
7
- import { Form as DefaultEntityForm } from '@irontec/ivoz-ui/entities/DefaultEntityBehavior/Form';
4
+ import useFkChoices from '@irontec-voip/ivoz-ui/entities/data/useFkChoices';
5
+ import defaultEntityBehavior, { EntityFormProps, FieldsetGroups } from '@irontec-voip/ivoz-ui/entities/DefaultEntityBehavior';
6
+ import _ from '@irontec-voip/ivoz-ui/services/translations/translate';
7
+ import { Form as DefaultEntityForm } from '@irontec-voip/ivoz-ui/entities/DefaultEntityBehavior/Form';
8
8
  import { foreignKeyGetter } from './ForeignKeyGetter';
9
9
 
10
10
  const Form = (props: EntityFormProps): JSX.Element => {
@@ -1,10 +1,10 @@
1
1
  ---
2
2
  to: src/entities/<%= Name %>/SelectOptions.ts
3
3
  ---
4
- import defaultEntityBehavior from '@irontec/ivoz-ui/entities/DefaultEntityBehavior';
5
- import { SelectOptionsType } from '@irontec/ivoz-ui/entities/EntityInterface';
4
+ import defaultEntityBehavior from '@irontec-voip/ivoz-ui/entities/DefaultEntityBehavior';
5
+ import { SelectOptionsType } from '@irontec-voip/ivoz-ui/entities/EntityInterface';
6
6
  import { <%= Name %>PropertiesList } from './<%= Name %>Properties';
7
- import { DropdownChoices } from '@irontec/ivoz-ui';
7
+ import { DropdownChoices } from '@irontec-voip/ivoz-ui';
8
8
  import store from 'store';
9
9
 
10
10
  const <%= Name %>SelectOptions: SelectOptionsType = ({ callback, cancelToken }): Promise<unknown> => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@irontec/ivoz-ui",
3
- "version": "1.3.11",
3
+ "version": "1.3.15",
4
4
  "description": "UI library used in ivozprovider",
5
5
  "license": "GPL-3.0",
6
6
  "main": "index.js",
@@ -12,5 +12,6 @@ interface StyledUploadButtonLabelProps {
12
12
  export declare const StyledUploadButtonLabel: import("@emotion/styled").StyledComponent<StyledUploadButtonLabelProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
13
13
  export declare const StyledFileNameContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
14
14
  export declare const StyledImageContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
15
+ export declare const StyledImagePreview: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
15
16
  export declare const StyledTextContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
16
17
  export {};
@@ -37,6 +37,10 @@ export const StyledImageContainer = styled('div')({
37
37
  color: '#A3A4A8',
38
38
  },
39
39
  });
40
+ export const StyledImagePreview = styled('img')({
41
+ maxWidth: '300px',
42
+ height: 'auto',
43
+ });
40
44
  export const StyledTextContainer = styled('div')({
41
45
  color: '#B2B3B6',
42
46
  fontSize: '14px',
@@ -1,15 +1,48 @@
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
+ };
1
10
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
11
  import AccountCircleIcon from '@mui/icons-material/AccountCircle';
12
+ import { useEffect, useState } from 'react';
3
13
  import _ from '../../../../translations/translate';
4
- import { StyledFileUploaderContainer, StyledImageContainer, StyledTextContainer, StyledUploadButtonLabel, } from '../FileUploader.styles';
14
+ import { StyledFileUploaderContainer, StyledImageContainer, StyledImagePreview, StyledTextContainer, StyledUploadButtonLabel, } from '../FileUploader.styles';
15
+ import { useStoreActions } from '../../../../../store';
5
16
  export const ImageFileUploader = (props) => {
6
17
  var _a, _b;
7
- const { _columnName, accept, values, disabled, handleDownload, changeHandler, onBlur, } = props;
18
+ const { _columnName, accept, values, disabled, handleDownload, changeHandler, onBlur, downloadPath, } = props;
8
19
  const fileValue = values[_columnName];
9
20
  const id = `${_columnName}-file-upload`;
10
21
  const fileName = (fileValue === null || fileValue === void 0 ? void 0 : fileValue.file) ? (_a = fileValue.file) === null || _a === void 0 ? void 0 : _a.name : fileValue === null || fileValue === void 0 ? void 0 : fileValue.baseName;
11
22
  const fileSize = (fileValue === null || fileValue === void 0 ? void 0 : fileValue.file) ? (_b = fileValue.file) === null || _b === void 0 ? void 0 : _b.size : fileValue === null || fileValue === void 0 ? void 0 : fileValue.fileSize;
12
23
  const fileSizeMb = Math.round(((fileSize || 0) / 1024 / 1024) * 10) / 10;
24
+ const apiDownload = useStoreActions((actions) => {
25
+ return actions.api.download;
26
+ });
27
+ const [imageSrc, setImageSrc] = useState(null);
28
+ useEffect(() => {
29
+ setImageSrc(null);
30
+ if (fileValue.file) {
31
+ const reader = new FileReader();
32
+ reader.onloadend = () => {
33
+ setImageSrc(reader.result);
34
+ };
35
+ reader.readAsDataURL(fileValue.file);
36
+ return;
37
+ }
38
+ apiDownload({
39
+ path: downloadPath,
40
+ params: {},
41
+ successCallback: (data) => __awaiter(void 0, void 0, void 0, function* () {
42
+ setImageSrc(URL.createObjectURL(data));
43
+ }),
44
+ });
45
+ }, [fileValue.file]);
13
46
  return (_jsxs(_Fragment, { children: [_jsxs(StyledFileUploaderContainer, { children: [_jsx("input", { style: { display: 'none' }, id: id, type: 'file', accept: accept, onChange: (event) => {
14
47
  const files = event.target.files || [];
15
48
  const value = Object.assign(Object.assign({}, fileValue), { file: files[0] });
@@ -21,5 +54,5 @@ export const ImageFileUploader = (props) => {
21
54
  };
22
55
  changeHandler(changeEvent);
23
56
  onBlur(changeEvent);
24
- } }), fileName && (_jsx(StyledImageContainer, Object.assign({ className: disabled ? 'disabled' : '' }, { children: values.id && _jsx(AccountCircleIcon, { onClick: handleDownload }) }))), _jsxs(StyledTextContainer, { children: [_jsx("span", { children: "JPG, JPEG, PNG format" }), _jsx("span", { children: "Maximum 500KB" }), !disabled && (_jsx(StyledUploadButtonLabel, Object.assign({ htmlFor: id }, { children: _('Upload image') }))), fileName && (_jsxs("span", { children: [fileName, " (", fileSizeMb, "MB)"] }))] })] }), _jsx("div", Object.assign({ className: 'uploader-backdrop' }, { children: "Image" }))] }));
57
+ } }), fileName && (_jsx(StyledImageContainer, Object.assign({ className: disabled ? 'disabled' : '' }, { children: imageSrc ? (_jsx(StyledImagePreview, { src: imageSrc, onClick: handleDownload })) : (values.id && _jsx(AccountCircleIcon, { onClick: handleDownload })) }))), _jsxs(StyledTextContainer, { children: [_jsx("span", { children: "JPG, JPEG, PNG format" }), _jsx("span", { children: "Maximum 500KB" }), !disabled && (_jsx(StyledUploadButtonLabel, Object.assign({ htmlFor: id }, { children: _('Upload image') }))), fileName && (_jsxs("span", { children: [fileName, " (", fileSizeMb, "MB)"] }))] })] }), _jsx("div", Object.assign({ className: 'uploader-backdrop' }, { children: "Image" }))] }));
25
58
  };