@openfin/ui-library 0.1.19 → 0.1.20-alpha.1623952084

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.
@@ -48,10 +48,10 @@ const InputContainer = styled_components_1.default(Box_1.Box) `
48
48
  height: var(--px-toggle);
49
49
  width: calc(2 * var(--px-toggle));
50
50
  border: 1px solid
51
- ${({ isChecked, theme }) => (isChecked ? theme.palette.brandPrimary : theme.palette.inputBg)};
51
+ ${({ isChecked, theme }) => isChecked ? theme.palette.brandPrimary : theme.palette.background6};
52
52
  border-radius: calc(0.5 * var(--px-toggle));
53
53
 
54
- background: ${({ isChecked, theme }) => isChecked ? theme.palette.brandPrimary : theme.palette.inputBg};
54
+ background: ${({ isChecked, theme }) => isChecked ? theme.palette.brandPrimary : theme.palette.background6};
55
55
  transition: background var(--openfin-ui-globalTransition),
56
56
  border-color var(---openfin-ui-globalTransition);
57
57
 
@@ -3,8 +3,8 @@ 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
- isFullWidth?: true;
8
8
  } & WithStatusProps;
9
9
  /**
10
10
  * @private This should not be exposed beyond the ui-library.
@@ -12,9 +12,7 @@ export declare type BaseInputProps = InputHTMLAttributes<HTMLInputElement> & {
12
12
  export declare const BaseInput: import("react").ForwardRefExoticComponent<InputHTMLAttributes<HTMLInputElement> & {
13
13
  message?: string | undefined;
14
14
  label?: string | undefined;
15
+ type?: string | undefined;
15
16
  renderInput?: Function | undefined;
16
- isFullWidth?: true | undefined;
17
17
  } & WithStatusProps & import("react").RefAttributes<HTMLInputElement>>;
18
- export declare const StyledInputField: import("styled-components").StyledComponent<"input", import("styled-components").DefaultTheme, InputHTMLAttributes<HTMLInputElement> & WithStatusProps & {
19
- isFullWidth?: true | undefined;
20
- }, never>;
18
+ export declare const StyledInputField: import("styled-components").StyledComponent<"input", import("styled-components").DefaultTheme, InputHTMLAttributes<HTMLInputElement> & WithStatusProps, never>;
@@ -25,13 +25,30 @@ 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
+ justify-content: ${({ inline }) => (inline ? 'flex-end' : 'flex-start')};
40
+ width: 100%;
41
+
42
+ ${({ inline, theme }) => inline &&
43
+ `
44
+ ${InputLabel} {
45
+ cursor: pointer;
46
+ margin-bottom: 0;
47
+ margin-left: ${theme.px.small};
48
+ font-weight: ${theme.fontWeight.normal};
49
+ }
50
+ `}
51
+ `;
35
52
  const InputLabel = styled_components_1.default(Text_1.Text) `
36
53
  margin-bottom: ${({ theme }) => theme.px.small};
37
54
  `;
@@ -43,8 +60,8 @@ const InputContainer = styled_components_1.default(Box_1.Box) `
43
60
  font-size: ${({ theme }) => theme.fontSize.base};
44
61
  `;
45
62
  exports.StyledInputField = styled_components_1.default.input `
46
- background: ${({ theme }) => theme.palette.inputBg};
47
- border: 1px solid ${({ theme }) => theme.palette.inputBg};
63
+ background: ${({ theme }) => theme.palette.background5};
64
+ border: 1px solid ${({ theme }) => theme.palette.background6};
48
65
  border-color: ${({ theme, status }) => ThemeProvider_1.getStatusColor(theme, status, 'inputBg')};
49
66
  border-radius: ${({ theme }) => theme.radius.small};
50
67
  box-shadow: ${({ theme }) => theme.shadow.base};
@@ -52,7 +69,7 @@ exports.StyledInputField = styled_components_1.default.input `
52
69
  font-size: ${({ theme }) => theme.fontSize.base};
53
70
  padding: ${({ theme }) => `${theme.px.small} ${theme.px.base}`};
54
71
  transition: border-color var(--openfin-ui-globalTransition);
55
- width: ${({ isFullWidth }) => isFullWidth && '100%'};
72
+ width: 100%;
56
73
 
57
74
  &:focus {
58
75
  outline: 0;
@@ -0,0 +1,10 @@
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
+ } & 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,11 +58,12 @@ 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;
65
65
  border-radius: ${({ theme }) => theme.radius.small};
66
+ width: 100%;
66
67
  `;
67
68
  const ControlContainer = styled_components_1.default(Box_1.Box) `
68
69
  align-items: center;
@@ -4,6 +4,6 @@ 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
- isFullWidth?: true | undefined;
9
9
  } & import("../../system/HOC").WithStatusProps & import("react").RefAttributes<HTMLInputElement>>;
@@ -17,8 +17,8 @@ export declare const Color: {
17
17
  readonly neutralGray: "#7D808A";
18
18
  readonly darkGray1: "#53565F";
19
19
  readonly darkGray2: "#383A40";
20
- readonly darkGray3: "#24262B";
21
- readonly darkGray4: "#2F3136";
20
+ readonly darkGray3: "#2F3136";
21
+ readonly darkGray4: "#24262B";
22
22
  readonly darkGray5: "#1E1F23";
23
23
  readonly darkGray6: "#111214";
24
24
  readonly openFinDarkest: "#3D39CD";
@@ -41,8 +41,8 @@ exports.Color = {
41
41
  neutralGray: '#7D808A',
42
42
  darkGray1: '#53565F',
43
43
  darkGray2: '#383A40',
44
- darkGray3: '#24262B',
45
- darkGray4: '#2F3136',
44
+ darkGray3: '#2F3136',
45
+ darkGray4: '#24262B',
46
46
  darkGray5: '#1E1F23',
47
47
  darkGray6: '#111214',
48
48
  openFinDarkest: '#3D39CD',
@@ -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.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,
37
+ [palette_1.Palette.inputBg]: constants_1.Color.darkGray1, [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
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.19",
4
+ "version": "0.1.20-alpha.1623952084",
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"