@luomus/laji-form 14.3.6 → 14.3.7

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/dist/styles.css CHANGED
@@ -2559,7 +2559,8 @@ min-height: 20px;
2559
2559
  .laji-form .col-lg-1, .laji-form .col-lg-10, .laji-form .col-lg-11, .laji-form .col-lg-12, .laji-form .col-lg-2, .laji-form .col-lg-3, .laji-form .col-lg-4, .laji-form .col-lg-5, .laji-form .col-lg-6, .laji-form .col-lg-7, .laji-form .col-lg-8, .laji-form .col-lg-9,
2560
2560
  .laji-form .col-md-1, .laji-form .col-md-10, .laji-form .col-md-11, .laji-form .col-md-12, .laji-form .col-md-2, .laji-form .col-md-3, .laji-form .col-md-4, .laji-form .col-md-5, .laji-form .col-md-6, .laji-form .col-md-7, .laji-form .col-md-8, .laji-form .col-md-9,
2561
2561
  .laji-form .col-sm-1, .laji-form .col-sm-10, .laji-form .col-sm-11, .laji-form .col-sm-12, .laji-form .col-sm-2, .laji-form .col-sm-3, .laji-form .col-sm-4, .laji-form .col-sm-5, .laji-form .col-sm-6, .laji-form .col-sm-7, .laji-form .col-sm-8, .laji-form .col-sm-9,
2562
- .laji-form .col-xs-1, .laji-form .col-xs-10, .laji-form .col-xs-11, .laji-form .col-xs-12, .laji-form .col-xs-2, .laji-form .col-xs-3, .laji-form .col-xs-4, .laji-form .col-xs-5, .laji-form .col-xs-6, .laji-form .col-xs-7, .laji-form .col-xs-8, .laji-form .col-xs-9 {
2562
+ .laji-form .col-xs-1, .laji-form .col-xs-10, .laji-form .col-xs-11, .laji-form .col-xs-12, .laji-form .col-xs-2, .laji-form .col-xs-3, .laji-form .col-xs-4, .laji-form .col-xs-5, .laji-form .col-xs-6, .laji-form .col-xs-7, .laji-form .col-xs-8, .laji-form .col-xs-9,
2563
+ .laji-form .col-1, .laji-form .col-10, .laji-form .col-11, .laji-form .col-12, .laji-form .col-2, .laji-form .col-3, .laji-form .col-4, .laji-form .col-5, .laji-form .col-6, .laji-form .col-7, .laji-form .col-8, .laji-form .col-9 {
2563
2564
  padding-right:3px;
2564
2565
  padding-left:3px;
2565
2566
  }
@@ -101,6 +101,7 @@ const fields = importLocalComponents("fields", [
101
101
  "SortArrayField",
102
102
  "InputWithDefaultValueButtonField",
103
103
  "MultiTagArrayField",
104
+ "PdfArrayField",
104
105
  { "InputTransformerField": "ConditionalOnChangeField" },
105
106
  { "ConditionalField": "ConditionalUiSchemaField" },
106
107
  { "UnitRapidField": "UnitShorthandField" },
@@ -34,7 +34,7 @@ export default class ImageArrayField extends React.Component<FieldProps, ImageAr
34
34
  renderModalMedia: () => JSX.Element;
35
35
  formatValue(value: string[], options: any, props: FieldProps): string | null;
36
36
  }
37
- interface MediaArrayState {
37
+ export interface MediaArrayState {
38
38
  tmpMedias: number[];
39
39
  addModal?: any;
40
40
  dragging?: boolean;
@@ -150,4 +150,23 @@ export declare function MediaArrayField<LFC extends Constructor<React.Component<
150
150
  };
151
151
  displayName: string;
152
152
  } & LFC;
153
+ interface ThumbnailProps {
154
+ id?: string;
155
+ apiClient: ApiClient;
156
+ apiEndpoint?: string;
157
+ dataURL?: string;
158
+ loading?: boolean;
159
+ }
160
+ interface ThumbnailState {
161
+ url?: string;
162
+ }
163
+ export declare class Thumbnail extends React.PureComponent<ThumbnailProps, ThumbnailState> {
164
+ mounted: boolean;
165
+ constructor(props: ThumbnailProps);
166
+ componentDidMount(): void;
167
+ componentWillUnmount(): void;
168
+ UNSAFE_componentWillReceiveProps(props: ThumbnailProps): void;
169
+ updateURL: ({ id, apiClient, apiEndpoint }: ThumbnailProps) => void;
170
+ render(): JSX.Element | null;
171
+ }
153
172
  export {};
@@ -17,7 +17,7 @@ var __rest = (this && this.__rest) || function (s, e) {
17
17
  return t;
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.MediaArrayField = void 0;
20
+ exports.Thumbnail = exports.MediaArrayField = void 0;
21
21
  const React = require("react");
22
22
  const PropTypes = require("prop-types");
23
23
  const immutability_helper_1 = require("immutability-helper");
@@ -663,10 +663,10 @@ exports.MediaArrayField = MediaArrayField;
663
663
  class Thumbnail extends React.PureComponent {
664
664
  constructor(props) {
665
665
  super(props);
666
- this.updateURL = ({ id, apiClient }) => {
666
+ this.updateURL = ({ id, apiClient, apiEndpoint = "images" }) => {
667
667
  if (!id)
668
668
  return;
669
- apiClient.fetchCached(`/images/${id}`, undefined, { failSilently: true }).then((response) => {
669
+ apiClient.fetchCached(`/${apiEndpoint}/${id}`, undefined, { failSilently: true }).then((response) => {
670
670
  if (!this.mounted)
671
671
  return;
672
672
  this.setState({ url: response.squareThumbnailURL });
@@ -694,3 +694,4 @@ class Thumbnail extends React.PureComponent {
694
694
  : img;
695
695
  }
696
696
  }
697
+ exports.Thumbnail = Thumbnail;
@@ -0,0 +1,21 @@
1
+ import * as React from "react";
2
+ import { FieldProps } from "../LajiForm";
3
+ import { MediaArrayState } from "./ImageArrayField";
4
+ export default class PdfArrayField extends React.Component<FieldProps, MediaArrayState> {
5
+ ALLOWED_FILE_TYPES: string[];
6
+ ACCEPT_FILE_TYPES: string[];
7
+ MAX_FILE_SIZE: number;
8
+ KEY: string;
9
+ ENDPOINT: string;
10
+ GLYPH: string;
11
+ TRANSLATION_TAKE_NEW: string;
12
+ TRANSLATION_SELECT_FILE: string;
13
+ TRANSLATION_NO_MEDIA: string;
14
+ CONTAINER_CLASS: string;
15
+ METADATA_FORM_ID: string;
16
+ renderMedia: (id: string) => JSX.Element;
17
+ renderLoadingMedia: (id: string) => JSX.Element;
18
+ onMediaClick: (i: number) => any;
19
+ renderModalMedia: () => JSX.Element;
20
+ formatValue(value: string[], options: any, props: FieldProps): string | null;
21
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const React = require("react");
10
+ const ImageArrayField_1 = require("./ImageArrayField");
11
+ let PdfArrayField = class PdfArrayField extends React.Component {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.ALLOWED_FILE_TYPES = ["application/pdf"];
15
+ this.ACCEPT_FILE_TYPES = ["application/pdf"];
16
+ this.MAX_FILE_SIZE = 20000000;
17
+ this.KEY = "PDF";
18
+ this.ENDPOINT = "pdf";
19
+ this.GLYPH = "paperclip";
20
+ this.TRANSLATION_TAKE_NEW = "";
21
+ this.TRANSLATION_SELECT_FILE = "";
22
+ this.TRANSLATION_NO_MEDIA = "";
23
+ this.CONTAINER_CLASS = "pdf-container";
24
+ this.METADATA_FORM_ID = "MHL.1070";
25
+ this.renderMedia = (id) => React.createElement(ImageArrayField_1.Thumbnail, { id: id, apiClient: this.props.formContext.apiClient, apiEndpoint: this.ENDPOINT });
26
+ this.renderLoadingMedia = (id) => React.createElement(ImageArrayField_1.Thumbnail, { dataURL: id, loading: true, apiClient: this.props.formContext.apiClient, apiEndpoint: this.ENDPOINT });
27
+ this.onMediaClick = (i) => this.openModalFor(i);
28
+ this.renderModalMedia = () => React.createElement("img", { src: this.state.modalMediaSrc });
29
+ }
30
+ formatValue(value, options, props) {
31
+ const { translations } = props.formContext;
32
+ return value && value.length
33
+ ? `${value.length} ${translations.HowManyFiles}`
34
+ : null;
35
+ }
36
+ };
37
+ PdfArrayField = __decorate([
38
+ ImageArrayField_1.MediaArrayField
39
+ ], PdfArrayField);
40
+ exports.default = PdfArrayField;
@@ -244,7 +244,7 @@ function handlesArrayKeys(ComposedComponent) {
244
244
  this.customEventListeners.forEach(params => customEvents.remove(props.idSchema.$id, ...params));
245
245
  }
246
246
  },
247
- _a.displayName = utils_1.getReactComponentName(ComposedComponent),
247
+ _a.displayName = utils_1.getReactComponentName(ComposedComponent) + "_handlesArrayKeys",
248
248
  _a;
249
249
  }
250
250
  exports.handlesArrayKeys = handlesArrayKeys;
@@ -17,10 +17,10 @@ const TitleField = ({ title, id, formData, style, uiSchema = {}, registry = {} }
17
17
  return null;
18
18
  }
19
19
  const helpComponent = help ? React.createElement(components_1.Help, null) : null;
20
- let titleTextContent = (React.createElement(React.Fragment, null,
20
+ let titleTextContent = React.createElement("span", null,
21
21
  React.createElement("span", { dangerouslySetInnerHTML: { __html: title } }),
22
22
  " ",
23
- helpComponent));
23
+ helpComponent);
24
24
  if (help) {
25
25
  const tooltipElem = (React.createElement(Tooltip, { id: id + "-tooltip" },
26
26
  React.createElement("span", null,
package/lib/themes/bs5.js CHANGED
@@ -50,7 +50,7 @@ Panel.Collapse = React.forwardRef((_a, ref) => {
50
50
  Panel.Footer = react_bootstrap_5_1.Card.Footer;
51
51
  const Glyphicon = React.forwardRef((_a, ref) => {
52
52
  var { glyph } = _a, props = __rest(_a, ["glyph"]);
53
- return (React.createElement(react_fontawesome_1.FontAwesomeIcon, Object.assign({ icon: glyphicon_fa_mapping_1.mapping[glyph] }, props, { ref: ref })));
53
+ return (React.createElement(react_fontawesome_1.FontAwesomeIcon, Object.assign({ className: "glyphicon", icon: glyphicon_fa_mapping_1.mapping[glyph] }, props, { ref: ref })));
54
54
  });
55
55
  const _Modal = react_bootstrap_5_1.Modal;
56
56
  const _InputGroup = react_bootstrap_5_1.InputGroup;
@@ -819,6 +819,11 @@
819
819
  "en": "photos",
820
820
  "sv": "foton"
821
821
  },
822
+ "howManyFiles": {
823
+ "fi": "tiedostoa",
824
+ "en": "files",
825
+ "sv": "filer"
826
+ },
822
827
  "sortStrategyDefault": {
823
828
  "fi": "Oletus",
824
829
  "en": "Default",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luomus/laji-form",
3
- "version": "14.3.6",
3
+ "version": "14.3.7",
4
4
  "description": "React module capable of building dynamic forms from Laji form json schemas",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -18,7 +18,8 @@
18
18
  "test": "HOST=127.0.0.1 PORT=8083 protractor protractor.conf.js",
19
19
  "test:multi": "TEST_BROWSER=multi HOST=127.0.0.1 PORT=8083 protractor protractor.conf.js",
20
20
  "test:ffox": "TEST_BROWSER=firefox HOST=127.0.0.1 PORT=8083 protractor protractor.conf.js",
21
- "test:debug": "HOST=127.0.0.1 PORT=8083 HEADLESS=false node --inspect-brk node_modules/protractor/bin/protractor protractor.conf.js"
21
+ "test:debug": "HOST=127.0.0.1 PORT=8083 HEADLESS=false node --inspect-brk node_modules/protractor/bin/protractor protractor.conf.js",
22
+ "patch": "patch-package"
22
23
  },
23
24
  "keywords": [
24
25
  "react-jsonschema-form",
@@ -69,6 +70,7 @@
69
70
  "eslint-plugin-react-hooks": "^4.2.0",
70
71
  "mini-css-extract-plugin": "^2.1.0",
71
72
  "notus": "^0.3.2",
73
+ "patch-package": "^8.0.0",
72
74
  "protractor": "^7.0.0",
73
75
  "protractor-console-plugin": "^0.1.1",
74
76
  "querystring": "^0.2.1",