@gpa-gemstone/react-forms 1.1.85 → 1.1.87

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.
@@ -1,5 +1,4 @@
1
1
  import * as moment from 'moment';
2
- import { Accuracy } from './DateTimeUI/Clock';
3
2
  import { Gemstone } from '@gpa-gemstone/application-typings';
4
3
  export type TimeUnit = ('datetime-local' | 'date' | 'time');
5
4
  interface IProps<T> extends Gemstone.TSX.Interfaces.IBaseFormProps<T> {
@@ -8,7 +7,7 @@ interface IProps<T> extends Gemstone.TSX.Interfaces.IBaseFormProps<T> {
8
7
  Format?: string;
9
8
  Type?: TimeUnit;
10
9
  AllowEmpty?: boolean;
11
- Accuracy?: Accuracy;
10
+ Accuracy?: Gemstone.TSX.Types.Accuracy;
12
11
  MinDate?: moment.Moment;
13
12
  }
14
13
  /**
@@ -1,9 +1,9 @@
1
1
  import * as moment from 'moment';
2
+ import { Gemstone } from '@gpa-gemstone/application-typings';
2
3
  interface IProps {
3
4
  DateTime: moment.Moment | undefined;
4
5
  Setter: (record: moment.Moment) => void;
5
- Accuracy?: Accuracy;
6
+ Accuracy?: Gemstone.TSX.Types.Accuracy;
6
7
  }
7
- export type Accuracy = ('minute' | 'second' | 'millisecond');
8
8
  export default function Clock(props: IProps): JSX.Element;
9
9
  export {};
@@ -1,6 +1,6 @@
1
1
  import * as moment from 'moment';
2
2
  import { TimeUnit } from '../DatePicker';
3
- import { Accuracy } from './Clock';
3
+ import { Gemstone } from '@gpa-gemstone/application-typings';
4
4
  interface IProps {
5
5
  DateTime: moment.Moment | undefined;
6
6
  Setter: (record: moment.Moment) => void;
@@ -10,7 +10,7 @@ interface IProps {
10
10
  Show: boolean;
11
11
  Top: number;
12
12
  Center: number;
13
- Accuracy?: Accuracy;
13
+ Accuracy?: Gemstone.TSX.Types.Accuracy;
14
14
  }
15
15
  export default function DateTimePopup(props: IProps): JSX.Element | null;
16
16
  export {};
package/lib/FileUpload.js CHANGED
@@ -78,7 +78,7 @@ var FileUpload = function (props) {
78
78
  "File Size: ",
79
79
  formatFileSize(fileSize))))
80
80
  :
81
- React.createElement("div", { className: 'row', onDragOver: handleDragOver, onDrop: handleDrop, style: { border: '2px dashed var(--secondary)' } },
81
+ React.createElement("div", { className: 'row', onDragOver: handleDragOver, onDrop: handleDrop, style: { border: '2px dashed var(--secondary)', borderRadius: '0.5em' } },
82
82
  React.createElement("div", { className: 'col-12 pt-3 pb-3 d-flex justify-content-center align-items-center' },
83
83
  React.createElement(gpa_symbols_1.ReactIcons.Image, { Size: 100 }),
84
84
  React.createElement("span", null, "Drag and Drop")))));
@@ -12,11 +12,11 @@ interface IProps<T> extends Gemstone.TSX.Interfaces.IBaseFormProps<T> {
12
12
  */
13
13
  AllowCustom?: boolean;
14
14
  /**
15
- * Function to perform a search and return a promise with a list of IOption and an optional callback
15
+ * Function to perform a search and return a promiselike object with a list of IOption and an optional callback
16
16
  * @param search - Search string
17
- * @returns {[promise: Promise<IOption[]>, callback?: () => void]}
17
+ * @returns {[promise: PromiseLike<IOption[]>, callback?: () => void]}
18
18
  */
19
- Search: (search: string) => [Promise<IOption[]>, () => void];
19
+ Search: (search: string) => [PromiseLike<IOption[]>, () => void];
20
20
  /**
21
21
  * CSS styles to apply to the form group
22
22
  * @type {React.CSSProperties}
@@ -21,17 +21,6 @@
21
21
  // Generated original version of source code.
22
22
  //
23
23
  // ******************************************************************************************************
24
- var __assign = (this && this.__assign) || function () {
25
- __assign = Object.assign || function(t) {
26
- for (var s, i = 1, n = arguments.length; i < n; i++) {
27
- s = arguments[i];
28
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
29
- t[p] = s[p];
30
- }
31
- return t;
32
- };
33
- return __assign.apply(this, arguments);
34
- };
35
24
  Object.defineProperty(exports, "__esModule", { value: true });
36
25
  exports.default = SearchableSelect;
37
26
  var React = require("react");
@@ -58,54 +47,57 @@ function SearchableSelect(props) {
58
47
  return callback;
59
48
  }
60
49
  }, [props.GetLabel]);
50
+ // Call props.Search every 500ms to avoid hammering the server while typing
61
51
  React.useEffect(function () {
62
52
  setLoading(true);
63
- var _a = props.Search(search), handle = _a[0], callback = _a[1];
64
- handle.then(function (d) {
65
- setResults(d.map(function (o) { return ({ Value: o.Value, Element: o.Label }); }));
66
- setLoading(false);
67
- }).catch(function () { return setLoading(false); });
68
- return callback;
53
+ var searchHandle;
54
+ var searchCallback;
55
+ var timeoutHandle = setTimeout(function () {
56
+ var _a;
57
+ _a = props.Search(search), searchHandle = _a[0], searchCallback = _a[1];
58
+ searchHandle.then(function (d) {
59
+ setResults(d.map(function (o) { return ({ Value: o.Value, Element: o.Label }); }));
60
+ setLoading(false);
61
+ }, function () {
62
+ setLoading(false);
63
+ });
64
+ }, 500);
65
+ return function () {
66
+ if (searchCallback != null)
67
+ searchCallback();
68
+ if (timeoutHandle != null)
69
+ clearTimeout(timeoutHandle);
70
+ };
69
71
  }, [search]);
70
- var handleOnBlur = React.useCallback(function () {
71
- setSearch(label);
72
- }, [label]);
72
+ var update = React.useCallback(function (record, selectedOption) {
73
+ var _a, _b;
74
+ var stringVal = (_b = (_a = record[props.Field]) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : '';
75
+ var newLabel = stringVal;
76
+ if (!React.isValidElement(selectedOption.Element))
77
+ newLabel = selectedOption.Element;
78
+ setLabel(newLabel);
79
+ props.Setter(record);
80
+ setSearch(newLabel);
81
+ }, [props.Setter, props.Field, label]);
73
82
  var options = React.useMemo(function () {
74
83
  var _a, _b;
75
84
  var ops = [];
76
85
  ops.push({
77
86
  Value: props.Record[props.Field],
78
87
  Element: React.createElement("div", { className: 'input-group' },
79
- React.createElement("input", { type: "text", className: "form-control", value: search, onChange: function (d) { return setSearch(d.target.value); }, onBlur: handleOnBlur, disabled: (_a = props.Disabled) !== null && _a !== void 0 ? _a : false }),
88
+ React.createElement("input", { type: "text", className: "form-control", value: search, onChange: function (d) { return setSearch(d.target.value); }, onBlur: function () { return setSearch(label); }, onClick: function (evt) { evt.preventDefault(); evt.stopPropagation(); }, disabled: (_a = props.Disabled) !== null && _a !== void 0 ? _a : false }),
80
89
  loading ?
81
90
  React.createElement("div", { className: "input-group-append" },
82
91
  React.createElement("span", { className: "input-group-text" },
83
92
  React.createElement(gpa_symbols_1.ReactIcons.SpiningIcon, null)))
84
93
  : null)
85
94
  });
86
- if (!((_b = props.AllowCustom) !== null && _b !== void 0 ? _b : false))
87
- ops.push({ Value: 'search-' + props.Record[props.Field], Element: label });
88
- else
89
- ops.push({ Value: search, Element: search });
95
+ if ((_b = props.AllowCustom) !== null && _b !== void 0 ? _b : false)
96
+ -ops.push({ Value: search, Element: React.createElement(React.Fragment, null,
97
+ search,
98
+ " (Entered Value)") });
90
99
  ops.push.apply(ops, results.filter(function (f) { return f.Value !== search && f.Value !== props.Record[props.Field]; }));
91
100
  return ops;
92
- }, [search, props.Record[props.Field], results, props.Disabled, loading, label, props.AllowCustom, handleOnBlur]);
93
- var update = React.useCallback(function (record, selectedOption) {
94
- var _a;
95
- var _b, _c;
96
- var stringVal = (_c = (_b = record[props.Field]) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : '';
97
- var newLabel = stringVal;
98
- if (!React.isValidElement(selectedOption.Element))
99
- newLabel = selectedOption.Element;
100
- setLabel(newLabel);
101
- if (stringVal.startsWith('search-')) {
102
- var value = stringVal.replace('search-', '');
103
- props.Setter(__assign(__assign({}, record), (_a = {}, _a[props.Field] = value, _a)));
104
- setSearch(newLabel !== null && newLabel !== void 0 ? newLabel : value);
105
- return;
106
- }
107
- props.Setter(record);
108
- setSearch(newLabel);
109
- }, [props.Setter, props.Field, label]);
101
+ }, [search, props.Record[props.Field], results, props.Disabled, loading, label]);
110
102
  return React.createElement(StylableSelect_1.default, { Record: props.Record, Field: props.Field, Setter: update, Label: props.Label, Disabled: props.Disabled, Help: props.Help, Style: props.Style, Options: options, BtnStyle: props.BtnStyle });
111
103
  }
@@ -121,7 +121,7 @@ function StylableSelect(props) {
121
121
  var showLabel = props.Label !== "";
122
122
  var showHelpIcon = props.Help !== undefined;
123
123
  var label = props.Label === undefined ? props.Field : props.Label;
124
- return (React.createElement("div", { ref: stylableSelect, style: { position: 'relative', display: 'inline-block', width: 'inherit' } },
124
+ return (React.createElement("div", { ref: stylableSelect, className: "form-group", style: { position: 'relative', display: 'inline-block', width: 'inherit' } },
125
125
  showHelpIcon || showLabel ?
126
126
  React.createElement("label", { className: "d-flex align-items-center" },
127
127
  React.createElement("span", null, showLabel ? label : ''),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gpa-gemstone/react-forms",
3
- "version": "1.1.85",
3
+ "version": "1.1.87",
4
4
  "description": "React Form modules for gpa webapps",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -45,9 +45,9 @@
45
45
  "typescript": "5.5.3"
46
46
  },
47
47
  "dependencies": {
48
- "@gpa-gemstone/application-typings": "0.0.83",
48
+ "@gpa-gemstone/application-typings": "0.0.84",
49
49
  "@gpa-gemstone/gpa-symbols": "0.0.49",
50
- "@gpa-gemstone/helper-functions": "0.0.39",
50
+ "@gpa-gemstone/helper-functions": "0.0.40",
51
51
  "@types/react": "^17.0.14",
52
52
  "@types/styled-components": "^5.1.11",
53
53
  "lodash": "^4.17.21",