@singularsystems/neo-react 1.0.2 → 1.0.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.
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { variant } from '@singularsystems/neo-core/dist/Components';
3
+ interface IBadgeProps {
4
+ /** Content of badge. */
5
+ text?: string;
6
+ /** Child Element */
7
+ children?: React.ReactNode;
8
+ /** Bootstrap variant. */
9
+ variant?: variant;
10
+ /** Set a custom variant for when a standard variant is not provided. */
11
+ customVariant?: string;
12
+ /** Changes the type of badge. */
13
+ isLarge?: boolean;
14
+ /** Changes the badge to a pill which results in rounder borders. */
15
+ isPill?: boolean;
16
+ }
17
+ export default class Badge extends React.Component<IBadgeProps & React.HTMLProps<HTMLDivElement>> {
18
+ constructor(props: IBadgeProps);
19
+ render(): React.JSX.Element;
20
+ }
21
+ export {};
@@ -0,0 +1,25 @@
1
+ import { __assign, __decorate, __extends, __metadata, __rest } from "tslib";
2
+ import React from 'react';
3
+ import { observer } from 'mobx-react';
4
+ import { Utils } from '@singularsystems/neo-core';
5
+ var Badge = /** @class */ (function (_super) {
6
+ __extends(Badge, _super);
7
+ function Badge(props) {
8
+ return _super.call(this, props) || this;
9
+ }
10
+ Badge.prototype.render = function () {
11
+ var _a;
12
+ var _b = this.props, text = _b.text, variant = _b.variant, customVariant = _b.customVariant, isLarge = _b.isLarge, isPill = _b.isPill, children = _b.children, domProps = __rest(_b, ["text", "variant", "customVariant", "isLarge", "isPill", "children"]);
13
+ var variantClassName = "badge badge-".concat(((_a = customVariant !== null && customVariant !== void 0 ? customVariant : variant) !== null && _a !== void 0 ? _a : "primary"));
14
+ var largeBadgeClassName = isLarge ? "badge-lg" : "";
15
+ var pillClassName = isPill ? "badge-pill" : "";
16
+ domProps.className = Utils.joinWithSpaces(domProps.className, variantClassName, pillClassName, largeBadgeClassName);
17
+ return (React.createElement("div", __assign({}, domProps), children !== null && children !== void 0 ? children : text));
18
+ };
19
+ Badge = __decorate([
20
+ observer,
21
+ __metadata("design:paramtypes", [Object])
22
+ ], Badge);
23
+ return Badge;
24
+ }(React.Component));
25
+ export default Badge;
@@ -45,7 +45,7 @@ var DatePicker = /** @class */ (function (_super) {
45
45
  void this.props.bind.value;
46
46
  }
47
47
  return (React.createElement("div", { className: "neo-datepicker-container", ref: this.container }, Components.DatePicker.mustShowInput(splitProps.dateProps) &&
48
- InputHelpers.surroundWithInputGroup(React.createElement("input", __assign({ type: "text" }, domProps, { ref: this.inputRef })), splitProps.editor, this.inputRef)));
48
+ InputHelpers.surroundWithInputGroup(React.createElement("input", __assign({ type: "text" }, domProps, { ref: this.inputRef })), splitProps.editor, domProps, this.inputRef)));
49
49
  };
50
50
  DatePicker.contextType = FormContext;
51
51
  DatePicker = __decorate([
@@ -90,6 +90,7 @@ export default class AutoCompleteDropDown<T> extends DropDownBase<T, IAutoComple
90
90
  private bindIdsProperty?;
91
91
  static getBindProp<T>(props: IAutoCompleteProps | IAutoCompleteMultiSelectProps): Model.IPropertyInstance<any>;
92
92
  private onKeyPress;
93
+ private setBindProperty;
93
94
  private mapTArrayToOptions;
94
95
  private onItemSelected;
95
96
  render(): React.JSX.Element;
@@ -11,29 +11,11 @@ import { NeoReactTypes } from '../../Modules/Types';
11
11
  var AutoCompleteDropDown = /** @class */ (function (_super) {
12
12
  __extends(AutoCompleteDropDown, _super);
13
13
  function AutoCompleteDropDown(props) {
14
- var _a;
15
14
  var _this = _super.call(this, props) || this;
16
15
  _this.asyncSelectImplementation = Misc.Globals.appService.get(NeoReactTypes.Components.AsyncSelect);
17
16
  _this.selectImplementation = Misc.Globals.appService.get(NeoReactTypes.Components.ReactSelect);
18
17
  _this.onKeyPress = _this.onKeyPress.bind(_this);
19
18
  _this.onItemSelected = _this.onItemSelected.bind(_this);
20
- var singleProps = _this.props, multiProps = _this.props;
21
- _this.bindProperty = (_a = singleProps.bind) !== null && _a !== void 0 ? _a : multiProps.bindItems;
22
- _this.fieldInfoContainer = Model.ModelFieldInfo.asModelFieldInfoContainer(_this.bindProperty.attachedTo);
23
- if (multiProps.bindIds) {
24
- if (multiProps.bindIds.propertyInfo) {
25
- var bindIdsProperty = multiProps.bindIds;
26
- _this.bindIdsProperty = bindIdsProperty;
27
- _this.bindIdsList = bindIdsProperty.value;
28
- }
29
- else {
30
- _this.bindIdsList = multiProps.bindIds;
31
- if (_this.fieldInfoContainer) {
32
- console.error("Warning: Pass a property instance as 'bindIds', otherwise the display values will not be captured.");
33
- _this.fieldInfoContainer = null;
34
- }
35
- }
36
- }
37
19
  return _this;
38
20
  }
39
21
  AutoCompleteDropDown.getBindProp = function (props) {
@@ -62,6 +44,29 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
62
44
  Utils.clearDebounce(this);
63
45
  }
64
46
  };
47
+ AutoCompleteDropDown.prototype.setBindProperty = function () {
48
+ var _a;
49
+ var singleProps = this.props, multiProps = this.props;
50
+ var newBind = (_a = singleProps.bind) !== null && _a !== void 0 ? _a : multiProps.bindItems;
51
+ if (this.bindProperty !== newBind) {
52
+ this.bindProperty = newBind;
53
+ this.fieldInfoContainer = Model.ModelFieldInfo.asModelFieldInfoContainer(this.bindProperty.attachedTo);
54
+ if (multiProps.bindIds) {
55
+ if (multiProps.bindIds.propertyInfo) {
56
+ var bindIdsProperty = multiProps.bindIds;
57
+ this.bindIdsProperty = bindIdsProperty;
58
+ this.bindIdsList = bindIdsProperty.value;
59
+ }
60
+ else {
61
+ this.bindIdsList = multiProps.bindIds;
62
+ if (this.fieldInfoContainer) {
63
+ console.error("Warning: Pass a property instance as 'bindIds', otherwise the display values will not be captured.");
64
+ this.fieldInfoContainer = null;
65
+ }
66
+ }
67
+ }
68
+ }
69
+ };
65
70
  AutoCompleteDropDown.prototype.mapTArrayToOptions = function (items) {
66
71
  var _this = this;
67
72
  if (items.length) {
@@ -124,6 +129,7 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
124
129
  var _this = this;
125
130
  var _a, _b, _c, _d, _e, _f, _g, _h;
126
131
  var _j = this.props, bind = _j.bind, bindDisplay = _j.bindDisplay, bindItems = _j.bindItems, bindIds = _j.bindIds, itemSource = _j.itemSource, items = _j.items, displayMember = _j.displayMember, valueMember = _j.valueMember, descriptionMember = _j.descriptionMember, option = _j.option, noRecordsPrompt = _j.noRecordsPrompt, typeToSearchPrompt = _j.typeToSearchPrompt, delayMs = _j.delayMs, minCharacters = _j.minCharacters, onItemSelected = _j.onItemSelected, fieldInfoLimit = _j.fieldInfoLimit, otherProps = __rest(_j, ["bind", "bindDisplay", "bindItems", "bindIds", "itemSource", "items", "displayMember", "valueMember", "descriptionMember", "option", "noRecordsPrompt", "typeToSearchPrompt", "delayMs", "minCharacters", "onItemSelected", "fieldInfoLimit"]);
132
+ this.setBindProperty();
127
133
  var splitProps = BindPropsHelper.splitCommonEditorProps(otherProps);
128
134
  var nativeProps = splitProps.rest;
129
135
  var bindItemsProperty = bindItems;
@@ -216,10 +222,10 @@ var AutoCompleteDropDown = /** @class */ (function (_super) {
216
222
  }
217
223
  };
218
224
  if (this.props.itemSource !== undefined) {
219
- return Tooltip.fromDataAttributes(InputHelpers.surroundWithInputGroup(React.createElement(this.asyncSelectImplementation, __assign({}, nativeProps, { placeholder: (_g = this.props.placeholder) !== null && _g !== void 0 ? _g : "", classNamePrefix: "react-select-bs", defaultOptions: defaultItems, loadOptions: this.onKeyPress, isMulti: bindItems !== undefined, noOptionsMessage: function (c) { var _a, _b; return c.inputValue && c.inputValue.length >= (minCharacters !== null && minCharacters !== void 0 ? minCharacters : 1) ? ((_a = _this.props.noRecordsPrompt) !== null && _a !== void 0 ? _a : "No records found") : ((_b = _this.props.typeToSearchPrompt) !== null && _b !== void 0 ? _b : "Type to search..."); }, value: value, onChange: this.onItemSelected, components: components })), splitProps.editor), nativeProps);
225
+ return Tooltip.fromDataAttributes(InputHelpers.surroundWithInputGroup(React.createElement(this.asyncSelectImplementation, __assign({}, nativeProps, { placeholder: (_g = this.props.placeholder) !== null && _g !== void 0 ? _g : "", classNamePrefix: "react-select-bs", defaultOptions: defaultItems, loadOptions: this.onKeyPress, isMulti: bindItems !== undefined, noOptionsMessage: function (c) { var _a, _b; return c.inputValue && c.inputValue.length >= (minCharacters !== null && minCharacters !== void 0 ? minCharacters : 1) ? ((_a = _this.props.noRecordsPrompt) !== null && _a !== void 0 ? _a : "No records found") : ((_b = _this.props.typeToSearchPrompt) !== null && _b !== void 0 ? _b : "Type to search..."); }, value: value, onChange: this.onItemSelected, components: components })), splitProps.editor, { disabled: nativeProps.isDisabled }), nativeProps);
220
226
  }
221
227
  else {
222
- return Tooltip.fromDataAttributes(InputHelpers.surroundWithInputGroup(React.createElement(this.selectImplementation, __assign({}, nativeProps, { placeholder: (_h = this.props.placeholder) !== null && _h !== void 0 ? _h : "", classNamePrefix: "react-select-bs", options: defaultItems, isLoading: this.isLoading, isMulti: bindItems !== undefined, noOptionsMessage: function (c) { var _a; return (_a = _this.props.noRecordsPrompt) !== null && _a !== void 0 ? _a : "No records found"; }, value: value, onChange: this.onItemSelected, components: components })), splitProps.editor), nativeProps);
228
+ return Tooltip.fromDataAttributes(InputHelpers.surroundWithInputGroup(React.createElement(this.selectImplementation, __assign({}, nativeProps, { placeholder: (_h = this.props.placeholder) !== null && _h !== void 0 ? _h : "", classNamePrefix: "react-select-bs", options: defaultItems, isLoading: this.isLoading, isMulti: bindItems !== undefined, noOptionsMessage: function (c) { var _a; return (_a = _this.props.noRecordsPrompt) !== null && _a !== void 0 ? _a : "No records found"; }, value: value, onChange: this.onItemSelected, components: components })), splitProps.editor, { disabled: nativeProps.isDisabled }), nativeProps);
223
229
  }
224
230
  };
225
231
  AutoCompleteDropDown.prototype.getOption = function (content, additionalClass) {
@@ -136,7 +136,7 @@ var DropDown = /** @class */ (function (_super) {
136
136
  addBlankItem && React.createElement("option", { className: "option-default" }, notFound ? "(Not found): ".concat(value) : nullText),
137
137
  items.map(function (item) { return (React.createElement("option", { value: item[_this.valueMember], key: item[_this.valueMember] }, item[_this.displayMember])); }));
138
138
  }
139
- return (InputHelpers.surroundWithInputGroup(control, splitProps.editor));
139
+ return (InputHelpers.surroundWithInputGroup(control, splitProps.editor, domProps));
140
140
  };
141
141
  DropDown.contextType = FormContext;
142
142
  DropDown = __decorate([
@@ -112,7 +112,7 @@ var Input = /** @class */ (function (_super) {
112
112
  splitProps.editor.append = this.props.bind.value ?
113
113
  React.createElement(Button, __assign({ size: "sm" }, buttonOptions, { icon: !this.showPassword ? "far-eye fa-fw" : "far-eye-slash fa-fw", onClick: function () { return _this.showPassword = !_this.showPassword; } })) : null;
114
114
  }
115
- return (InputHelpers.surroundWithInputGroup(inputElement, splitProps.editor, this.domRef));
115
+ return (InputHelpers.surroundWithInputGroup(inputElement, splitProps.editor, domProps, this.domRef));
116
116
  };
117
117
  Input.contextType = FormContext;
118
118
  __decorate([
@@ -2,6 +2,6 @@ import * as React from 'react';
2
2
  import { ICommonEditorProps } from './PropTypes';
3
3
  export declare class InputHelpers {
4
4
  private static iconFactory?;
5
- static surroundWithInputGroup<T extends React.ReactNode>(element: T, props: ICommonEditorProps, inputRef?: React.RefObject<HTMLElement>): React.JSX.Element | T;
5
+ static surroundWithInputGroup<T extends React.ReactNode>(element: T, props: ICommonEditorProps, domProps: React.HTMLProps<HTMLElement>, inputRef?: React.RefObject<HTMLElement>): React.JSX.Element | T;
6
6
  private static getElement;
7
7
  }
@@ -5,13 +5,13 @@ import BootstrapUtils from "./BootstrapUtils";
5
5
  var InputHelpers = /** @class */ (function () {
6
6
  function InputHelpers() {
7
7
  }
8
- InputHelpers.surroundWithInputGroup = function (element, props, inputRef) {
8
+ InputHelpers.surroundWithInputGroup = function (element, props, domProps, inputRef) {
9
9
  if (!this.iconFactory) {
10
10
  this.iconFactory = Misc.Globals.appService.get(NeoReactTypes.Components.IconFactory);
11
11
  }
12
12
  if (props.requiresGroup) {
13
- var isBsPre5 = BootstrapUtils.isPre5;
14
- return (React.createElement("div", { className: "input-group" },
13
+ var isBsPre5 = BootstrapUtils.isPre5, isDisabled = domProps.disabled || domProps.readOnly;
14
+ return (React.createElement("div", { className: "input-group" + (isDisabled ? " input-group-disabled" : "") },
15
15
  this.getElement(isBsPre5, "input-group-prepend", inputRef, props.prependText, props.prependIcon, props.prepend),
16
16
  element,
17
17
  this.getElement(isBsPre5, "input-group-append", inputRef, props.appendText, props.appendIcon, props.append)));
@@ -1,7 +1,11 @@
1
1
  import React from "react";
2
2
  import { Components } from "@singularsystems/neo-core";
3
3
  import CollapsableBase from '../CollapsableBase';
4
- export default class Alert extends CollapsableBase<Components.INotificationOptions & React.HTMLProps<HTMLDivElement>> {
4
+ interface IAlertProps {
5
+ isOutline?: boolean;
6
+ }
7
+ export default class Alert extends CollapsableBase<Components.INotificationOptions & IAlertProps & React.HTMLProps<HTMLDivElement>> {
5
8
  private iconFactory;
6
9
  render(): React.JSX.Element;
7
10
  }
11
+ export {};
@@ -13,8 +13,8 @@ var Alert = /** @class */ (function (_super) {
13
13
  return _this;
14
14
  }
15
15
  Alert.prototype.render = function () {
16
- var _a = this.props, variant = _a.variant, heading = _a.heading, show = _a.show, bindShow = _a.bindShow, autoCloseTimeout = _a.autoCloseTimeout, animateInitial = _a.animateInitial, state = _a.state, onHidden = _a.onHidden, refreshValue = _a.refreshValue, icon = _a.icon, native = __rest(_a, ["variant", "heading", "show", "bindShow", "autoCloseTimeout", "animateInitial", "state", "onHidden", "refreshValue", "icon"]);
17
- var className = Utils.joinWithSpaces(native.className, "alert", "alert-" + variant, "collapsable");
16
+ var _a = this.props, variant = _a.variant, heading = _a.heading, show = _a.show, bindShow = _a.bindShow, autoCloseTimeout = _a.autoCloseTimeout, animateInitial = _a.animateInitial, state = _a.state, onHidden = _a.onHidden, refreshValue = _a.refreshValue, icon = _a.icon, isOutline = _a.isOutline, native = __rest(_a, ["variant", "heading", "show", "bindShow", "autoCloseTimeout", "animateInitial", "state", "onHidden", "refreshValue", "icon", "isOutline"]);
17
+ var className = Utils.joinWithSpaces(native.className, "alert", "alert-" + variant, "collapsable" + (isOutline ? " alert-outline" : ""));
18
18
  if (bindShow) {
19
19
  className += " alert-dismissible";
20
20
  }
@@ -246,7 +246,7 @@ var NumberInput = /** @class */ (function (_super) {
246
246
  var decimals = NumberUtils.getDecimalPlaces(this.formatState.formatString);
247
247
  domProps.step = decimals === 0 ? "1" : "0.".concat("0".repeat(decimals - 1), "1");
248
248
  }
249
- return (InputHelpers.surroundWithInputGroup(React.createElement("input", __assign({}, domProps, { defaultValue: this.formatState.getFormattedValue(editorProps.bind.value), type: useNative ? "number" : "text", onChange: this.onChanged, ref: this.inputElement })), editorProps, this.inputElement));
249
+ return (InputHelpers.surroundWithInputGroup(React.createElement("input", __assign({}, domProps, { defaultValue: this.formatState.getFormattedValue(editorProps.bind.value), type: useNative ? "number" : "text", onChange: this.onChanged, ref: this.inputElement })), editorProps, domProps, this.inputElement));
250
250
  };
251
251
  NumberInput.contextType = FormContext;
252
252
  NumberInput = __decorate([
@@ -1,5 +1,6 @@
1
1
  import Alert from './Notifications/Alert';
2
2
  import AutoCompleteDropDown from './DropDown/AutoCompleteDropDown';
3
+ import Badge from './Badge';
3
4
  import Button from './Button';
4
5
  import Card from './Card';
5
6
  import Collapsable from './Collapsable';
@@ -39,4 +40,4 @@ import ToastContainer from './Notifications/ToastContainer';
39
40
  import Tooltip from './Tooltip';
40
41
  import TooltipProvider from './TooltipProvider';
41
42
  import ValidationSummary from './ValidationSummary';
42
- export { Alert, AutoCompleteDropDown, Button, Card, Checkbox, Collapsable, ColorPicker, ContextMenuContainer, DatePicker, DropDown, FileBasicInput, FileContext, FileDropArea, FileInput, FileUploadButton, FileUploadProgress, Form, FormContext, FormGroup, FormGroupFloating, FormGroupInline, GridLayout, Icon, Input, Link, Loader, Modal, ModalContainer, NumberInput, Pager, PagerControlsBasic, PageSizeControl, Passwordbox, ProgressBar, RadioList, Slider, TabContainer, Tab, Textbox, Toast, ToastContainer, Tooltip, TooltipProvider, ValidationSummary };
43
+ export { Alert, AutoCompleteDropDown, Badge, Button, Card, Checkbox, Collapsable, ColorPicker, ContextMenuContainer, DatePicker, DropDown, FileBasicInput, FileContext, FileDropArea, FileInput, FileUploadButton, FileUploadProgress, Form, FormContext, FormGroup, FormGroupFloating, FormGroupInline, GridLayout, Icon, Input, Link, Loader, Modal, ModalContainer, NumberInput, Pager, PagerControlsBasic, PageSizeControl, Passwordbox, ProgressBar, RadioList, Slider, TabContainer, Tab, Textbox, Toast, ToastContainer, Tooltip, TooltipProvider, ValidationSummary };
@@ -1,5 +1,6 @@
1
1
  import Alert from './Notifications/Alert';
2
2
  import AutoCompleteDropDown from './DropDown/AutoCompleteDropDown';
3
+ import Badge from './Badge';
3
4
  import Button from './Button';
4
5
  import Card from './Card';
5
6
  import Collapsable from './Collapsable';
@@ -39,4 +40,4 @@ import ToastContainer from './Notifications/ToastContainer';
39
40
  import Tooltip from './Tooltip';
40
41
  import TooltipProvider from './TooltipProvider';
41
42
  import ValidationSummary from './ValidationSummary';
42
- export { Alert, AutoCompleteDropDown, Button, Card, Checkbox, Collapsable, ColorPicker, ContextMenuContainer, DatePicker, DropDown, FileBasicInput, FileContext, FileDropArea, FileInput, FileUploadButton, FileUploadProgress, Form, FormContext, FormGroup, FormGroupFloating, FormGroupInline, GridLayout, Icon, Input, Link, Loader, Modal, ModalContainer, NumberInput, Pager, PagerControlsBasic, PageSizeControl, Passwordbox, ProgressBar, RadioList, Slider, TabContainer, Tab, Textbox, Toast, ToastContainer, Tooltip, TooltipProvider, ValidationSummary };
43
+ export { Alert, AutoCompleteDropDown, Badge, Button, Card, Checkbox, Collapsable, ColorPicker, ContextMenuContainer, DatePicker, DropDown, FileBasicInput, FileContext, FileDropArea, FileInput, FileUploadButton, FileUploadProgress, Form, FormContext, FormGroup, FormGroupFloating, FormGroupInline, GridLayout, Icon, Input, Link, Loader, Modal, ModalContainer, NumberInput, Pager, PagerControlsBasic, PageSizeControl, Passwordbox, ProgressBar, RadioList, Slider, TabContainer, Tab, Textbox, Toast, ToastContainer, Tooltip, TooltipProvider, ValidationSummary };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@singularsystems/neo-react",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "React application logic and components for the Neo client library",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,8 @@
1
+ div.badge {
2
+ &.badge-lg {
3
+ padding: 5px 10px;
4
+ min-width: 100px;
5
+ font-size: 0.8rem;
6
+ width: fit-content;
7
+ }
8
+ }
package/styles/Neo.scss CHANGED
@@ -1,3 +1,4 @@
1
+ @import './Badge.scss';
1
2
  @import './Button.scss';
2
3
  @import './Card.scss';
3
4
  @import './ColorPicker.scss';