@openfin/ui-library 0.1.18 → 0.1.19-alpha.1623856227

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.
@@ -3,6 +3,7 @@ import { WithStatusProps } from '../../system/HOC';
3
3
  export declare type BaseInputProps = InputHTMLAttributes<HTMLInputElement> & {
4
4
  message?: string;
5
5
  label?: string;
6
+ type?: string;
6
7
  renderInput?: Function;
7
8
  isFullWidth?: true;
8
9
  } & WithStatusProps;
@@ -12,6 +13,7 @@ export declare type BaseInputProps = InputHTMLAttributes<HTMLInputElement> & {
12
13
  export declare const BaseInput: import("react").ForwardRefExoticComponent<InputHTMLAttributes<HTMLInputElement> & {
13
14
  message?: string | undefined;
14
15
  label?: string | undefined;
16
+ type?: string | undefined;
15
17
  renderInput?: Function | undefined;
16
18
  isFullWidth?: true | undefined;
17
19
  } & WithStatusProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -25,13 +25,28 @@ const Text_1 = require("../../typography/Text");
25
25
  * @private This should not be exposed beyond the ui-library.
26
26
  */
27
27
  exports.BaseInput = react_1.forwardRef((_a, ref) => {
28
- var { className, renderInput, message, label, status, name } = _a, inputProps = __rest(_a, ["className", "renderInput", "message", "label", "status", "name"]);
29
- return (jsx_runtime_1.jsxs(InputContainer, Object.assign({ flexDirection: "column", alignItems: "flex-start" }, { children: [!!label && (jsx_runtime_1.jsx(InputLabel, Object.assign({ as: "label", htmlFor: name, weight: "bold" }, { children: label }), void 0)),
30
- !!renderInput && renderInput(Object.assign({ name, status }, inputProps)),
31
- !renderInput && (jsx_runtime_1.jsx(exports.StyledInputField, Object.assign({ className: className, name: name, status: status }, inputProps, { ref: ref }), void 0)),
28
+ var { className, renderInput, message, label, status, name, type } = _a, inputProps = __rest(_a, ["className", "renderInput", "message", "label", "status", "name", "type"]);
29
+ const displayLabelInline = type === 'checkbox' || type === 'radio';
30
+ return (jsx_runtime_1.jsxs(InputContainer, Object.assign({ flexDirection: "column", alignItems: "flex-start" }, { children: [jsx_runtime_1.jsxs(LabelWrapper, Object.assign({ inline: displayLabelInline }, { children: [!!label && (jsx_runtime_1.jsx(InputLabel, Object.assign({ as: "label", htmlFor: name, weight: "bold" }, { children: label }), void 0)),
31
+ !!renderInput && renderInput(Object.assign({ name, status }, inputProps)),
32
+ !renderInput && (jsx_runtime_1.jsx(exports.StyledInputField, Object.assign({ className: className, name: name, status: status }, inputProps, { ref: ref }), void 0))] }), void 0),
32
33
  !!message && jsx_runtime_1.jsx(InputMessage, Object.assign({ status: status }, { children: message }), void 0)] }), void 0));
33
34
  });
34
35
  exports.BaseInput.displayName = 'BaseInput';
36
+ const LabelWrapper = styled_components_1.default(Box_1.Box) `
37
+ align-items: ${({ inline }) => (inline ? 'center' : 'flex-start')};
38
+ flex-direction: ${({ inline }) => (inline ? 'row-reverse' : 'column')};
39
+
40
+ ${({ inline, theme }) => inline &&
41
+ `
42
+ ${InputLabel} {
43
+ cursor: pointer;
44
+ margin-bottom: 0;
45
+ margin-left: ${theme.px.small};
46
+ font-weight: ${theme.fontWeight.normal};
47
+ }
48
+ `}
49
+ `;
35
50
  const InputLabel = styled_components_1.default(Text_1.Text) `
36
51
  margin-bottom: ${({ theme }) => theme.px.small};
37
52
  `;
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import { BaseInputProps } from '../BaseInput';
3
+ import { WithStatusProps } from '../../system/HOC';
4
+ export declare type CheckboxProps = BaseInputProps;
5
+ export declare const Checkbox: React.ForwardRefExoticComponent<React.InputHTMLAttributes<HTMLInputElement> & {
6
+ message?: string | undefined;
7
+ label?: string | undefined;
8
+ type?: string | undefined;
9
+ renderInput?: Function | undefined;
10
+ isFullWidth?: true | undefined;
11
+ } & WithStatusProps & React.RefAttributes<HTMLInputElement>>;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __rest = (this && this.__rest) || function (s, e) {
22
+ var t = {};
23
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
24
+ t[p] = s[p];
25
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
26
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
27
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
28
+ t[p[i]] = s[p[i]];
29
+ }
30
+ return t;
31
+ };
32
+ var __importDefault = (this && this.__importDefault) || function (mod) {
33
+ return (mod && mod.__esModule) ? mod : { "default": mod };
34
+ };
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Checkbox = void 0;
37
+ const jsx_runtime_1 = require("react/jsx-runtime");
38
+ const React = __importStar(require("react"));
39
+ const styled_components_1 = __importDefault(require("styled-components"));
40
+ const BaseInput_1 = require("../BaseInput");
41
+ const Icon_1 = require("../../elements/Icon");
42
+ const ThemeProvider_1 = require("../../system/ThemeProvider");
43
+ exports.Checkbox = React.forwardRef((_a, ref) => {
44
+ var { status } = _a, props = __rest(_a, ["status"]);
45
+ return (jsx_runtime_1.jsx(BaseInput_1.BaseInput, Object.assign({}, props, { type: "checkbox", status: status, renderInput: (_a) => {
46
+ var inputProps = __rest(_a, []);
47
+ return (jsx_runtime_1.jsxs(Container, { children: [jsx_runtime_1.jsx(Input, Object.assign({ ref: ref, id: inputProps.name, type: "checkbox" }, inputProps), void 0),
48
+ jsx_runtime_1.jsx(Fauxbox, Object.assign({ status: status }, { children: jsx_runtime_1.jsx(CheckIcon, {}, void 0) }), void 0)] }, void 0));
49
+ } }), void 0));
50
+ });
51
+ exports.Checkbox.displayName = 'Checkbox';
52
+ const Container = styled_components_1.default.div `
53
+ display: inline-block;
54
+ position: relative;
55
+ `;
56
+ const Fauxbox = styled_components_1.default.div `
57
+ display: flex;
58
+ align-items: center;
59
+ justify-content: center;
60
+ height: ${({ theme }) => theme.px.base};
61
+ width: ${({ theme }) => theme.px.base};
62
+ border: 1px solid ${({ theme }) => theme.palette.textDefault};
63
+ border-color: ${({ theme, status }) => ThemeProvider_1.getStatusColor(theme, status, 'textDefault')};
64
+ border-radius: 2px;
65
+ pointer-events: none;
66
+ `;
67
+ const CheckIcon = styled_components_1.default(Icon_1.Icon).attrs({ icon: 'CheckIcon', size: 'small' }) `
68
+ opacity: 0;
69
+ `;
70
+ const Input = styled_components_1.default.input `
71
+ opacity: 0;
72
+ position: absolute;
73
+ width: 100%;
74
+ height: 100%;
75
+ cursor: pointer;
76
+
77
+ &:checked + ${Fauxbox + ' ' + CheckIcon} {
78
+ opacity: 1;
79
+ }
80
+
81
+ &:hover + ${Fauxbox} {
82
+ box-shadow: 0 0 1px 1px ${({ theme }) => theme.palette.inputFocused};
83
+ }
84
+
85
+ &:focus + ${Fauxbox} {
86
+ box-shadow: 0 0 1px 1px ${({ theme }) => theme.palette.inputFocused};
87
+ }
88
+
89
+ &:disabled {
90
+ cursor: not-allowed;
91
+ }
92
+
93
+ &:disabled + ${Fauxbox} {
94
+ opacity: 0.5;
95
+ }
96
+ `;
@@ -0,0 +1 @@
1
+ export * from './checkbox';
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./checkbox"), exports);
@@ -58,7 +58,7 @@ const StyledNumberInput = react_1.forwardRef((_a, ref) => {
58
58
  jsx_runtime_1.jsxs(ControlContainer, Object.assign({ flexDirection: "column", disabled: props.disabled }, { children: [jsx_runtime_1.jsx(ArrowControl, Object.assign({ onClick: onIncrement, disabled: props.disabled }, { children: jsx_runtime_1.jsx(Icon_1.Icon, { icon: "TriangleUpIcon" }, void 0) }), void 0),
59
59
  jsx_runtime_1.jsx(ArrowControl, Object.assign({ onClick: onDecrement, disabled: props.disabled }, { children: jsx_runtime_1.jsx(Icon_1.Icon, { icon: "TriangleDownIcon" }, void 0) }), void 0)] }), void 0)] }, void 0));
60
60
  });
61
- StyledNumberInput.displayName = "StyledNumberInput";
61
+ StyledNumberInput.displayName = 'StyledNumberInput';
62
62
  const StyledInputContainer = styled_components_1.default.div `
63
63
  position: relative;
64
64
  overflow: hidden;
@@ -4,6 +4,7 @@ export declare type TextInputProps = BaseInputProps;
4
4
  export declare const TextInput: import("react").ForwardRefExoticComponent<import("react").InputHTMLAttributes<HTMLInputElement> & {
5
5
  message?: string | undefined;
6
6
  label?: string | undefined;
7
+ type?: string | undefined;
7
8
  renderInput?: Function | undefined;
8
9
  isFullWidth?: true | undefined;
9
10
  } & import("../../system/HOC").WithStatusProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -34,6 +34,6 @@ exports.OpenFinDarkTheme = createTheme_1.createTheme(Object.assign(Object.assign
34
34
  // Brand
35
35
  [palette_1.Palette.brandSecondary]: constants_1.Color.darkGray2,
36
36
  // Inputs
37
- [palette_1.Palette.inputBg]: constants_1.Color.darkGray1, [palette_1.Palette.inputColor]: constants_1.Color.white, [palette_1.Palette.inputPlaceholder]: constants_1.Color.lightGray4, [palette_1.Palette.inputDisabled]: constants_1.Color.neutralGray, [palette_1.Palette.inputFocused]: constants_1.Color.lightGray4,
37
+ [palette_1.Palette.inputBg]: constants_1.Color.darkGray3, [palette_1.Palette.inputColor]: constants_1.Color.white, [palette_1.Palette.inputPlaceholder]: constants_1.Color.lightGray5, [palette_1.Palette.inputDisabled]: constants_1.Color.neutralGray, [palette_1.Palette.inputFocused]: constants_1.Color.lightGray5,
38
38
  // Text
39
- [palette_1.Palette.textDefault]: constants_1.Color.white, [palette_1.Palette.textHelp]: constants_1.Color.lightGray4, [palette_1.Palette.textInactive]: constants_1.Color.neutralGray }));
39
+ [palette_1.Palette.textDefault]: constants_1.Color.white, [palette_1.Palette.textHelp]: constants_1.Color.lightGray5, [palette_1.Palette.textInactive]: constants_1.Color.neutralGray }));
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export * from './components/elements/Loader';
6
6
  export * from './components/input/RawInput';
7
7
  export * from './components/input/TextInput';
8
8
  export * from './components/input/NumberInput';
9
+ export * from './components/input/Checkbox';
9
10
  export * from './components/layout/Box';
10
11
  export * from './components/layout/DefinitionList';
11
12
  export * from './components/system/GlobalStyles';
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ __exportStar(require("./components/elements/Loader"), exports);
31
31
  __exportStar(require("./components/input/RawInput"), exports);
32
32
  __exportStar(require("./components/input/TextInput"), exports);
33
33
  __exportStar(require("./components/input/NumberInput"), exports);
34
+ __exportStar(require("./components/input/Checkbox"), exports);
34
35
  __exportStar(require("./components/layout/Box"), exports);
35
36
  __exportStar(require("./components/layout/DefinitionList"), exports);
36
37
  __exportStar(require("./components/system/GlobalStyles"), exports);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openfin/ui-library",
3
3
  "description": "OpenFin UI Component Library",
4
- "version": "0.1.18",
4
+ "version": "0.1.19-alpha.1623856227",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "repository": "github:openfin/ui-library",
@@ -128,6 +128,9 @@
128
128
  "@typescript-eslint/no-unused-vars": "error",
129
129
  "@typescript-eslint/no-explicit-any": "error"
130
130
  },
131
+ "globals": {
132
+ "JSX": "readonly"
133
+ },
131
134
  "settings": {
132
135
  "react": {
133
136
  "version": "detect"