@openfin/ui-library 0.1.10-alpha.1619028249 → 0.1.10

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,3 +1,5 @@
1
+ import { InputHTMLAttributes } from 'react';
2
+ export declare type RawInputProps = InputHTMLAttributes<HTMLInputElement>;
1
3
  /**
2
4
  * Unstyled input extended by other components
3
5
  */
@@ -1,4 +1,7 @@
1
- import { FC } from 'react';
2
- import { BaseInputProps } from '../BaseInput';
3
- export declare type TextInputProps = BaseInputProps;
4
- export declare const TextInput: FC<TextInputProps>;
1
+ import { FC, InputHTMLAttributes } from 'react';
2
+ import { WithStatusProps } from '../../system/HOC';
3
+ export declare type TextInputProps = InputHTMLAttributes<HTMLInputElement> & {
4
+ message?: string;
5
+ label?: string;
6
+ };
7
+ export declare const TextInput: FC<TextInputProps & WithStatusProps>;
@@ -10,12 +10,55 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  }
11
11
  return t;
12
12
  };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
13
16
  Object.defineProperty(exports, "__esModule", { value: true });
14
17
  exports.TextInput = void 0;
15
18
  const jsx_runtime_1 = require("react/jsx-runtime");
16
- const BaseInput_1 = require("../BaseInput");
17
- const TextInput = (_a) => {
18
- var props = __rest(_a, []);
19
- return jsx_runtime_1.jsx(BaseInput_1.BaseInput, Object.assign({ type: "text" }, props), void 0);
20
- };
21
- exports.TextInput = TextInput;
19
+ const styled_components_1 = __importDefault(require("styled-components"));
20
+ const RawInput_1 = require("../RawInput");
21
+ const HOC_1 = require("../../system/HOC");
22
+ const Box_1 = require("../../layout/Box");
23
+ const Text_1 = require("../../typography/Text");
24
+ const ThemeProvider_1 = require("../../system/ThemeProvider");
25
+ exports.TextInput = HOC_1.withStatus((_a) => {
26
+ var { className, message, label, status, name } = _a, inputProps = __rest(_a, ["className", "message", "label", "status", "name"]);
27
+ 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)),
28
+ jsx_runtime_1.jsx(StyledInputField, Object.assign({ className: className, type: "text", name: name, status: status }, inputProps), void 0),
29
+ !!message && jsx_runtime_1.jsx(InputMessage, Object.assign({ status: status }, { children: message }), void 0)] }), void 0));
30
+ });
31
+ const InputLabel = styled_components_1.default(Text_1.Text) `
32
+ margin-bottom: ${({ theme }) => theme.px.small};
33
+ `;
34
+ const InputMessage = styled_components_1.default(Text_1.Text) `
35
+ color: ${({ theme, status }) => ThemeProvider_1.getStatusColor(theme, status, 'textHelp')};
36
+ margin-top: ${({ theme }) => theme.px.small};
37
+ `;
38
+ const InputContainer = styled_components_1.default(Box_1.Box) `
39
+ font-size: ${({ theme }) => theme.fontSize.base};
40
+ `;
41
+ const StyledInputField = styled_components_1.default(RawInput_1.RawInput) `
42
+ background: ${({ theme }) => theme.palette.inputBg};
43
+ border: 1px solid ${({ theme }) => theme.palette.inputBg};
44
+ border-color: ${({ theme, status }) => ThemeProvider_1.getStatusColor(theme, status, 'inputBg')};
45
+ border-radius: ${({ theme }) => theme.radius.small};
46
+ box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
47
+ color: ${({ theme }) => theme.palette.inputColor};
48
+ font-size: ${({ theme }) => theme.fontSize.base};
49
+ padding: ${({ theme }) => `${theme.px.small} ${theme.px.base}`};
50
+ transition: border-color var(--openfin-ui-globalTransition);
51
+
52
+ &:focus {
53
+ outline: 0;
54
+ border-color: ${({ theme }) => theme.palette.inputFocused};
55
+ }
56
+
57
+ &:disabled {
58
+ cursor: not-allowed;
59
+ }
60
+
61
+ &:disabled::placeholder {
62
+ color: ${({ theme }) => theme.palette.inputDisabled};
63
+ }
64
+ `;
package/dist/index.d.ts CHANGED
@@ -12,4 +12,5 @@ export * from './components/typography/Heading';
12
12
  export * from './components/typography/Text';
13
13
  export * from './hooks/useColorScheme';
14
14
  export * from './hooks/useMediaQuery';
15
+ export * from './assets/fonts';
15
16
  export * as StoryHelpers from './storybookHelpers';
package/dist/index.js CHANGED
@@ -37,4 +37,5 @@ __exportStar(require("./components/typography/Heading"), exports);
37
37
  __exportStar(require("./components/typography/Text"), exports);
38
38
  __exportStar(require("./hooks/useColorScheme"), exports);
39
39
  __exportStar(require("./hooks/useMediaQuery"), exports);
40
+ __exportStar(require("./assets/fonts"), exports);
40
41
  exports.StoryHelpers = __importStar(require("./storybookHelpers"));
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.10-alpha.1619028249",
4
+ "version": "0.1.10",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "repository": "github:openfin/ui-library",
@@ -153,7 +153,6 @@
153
153
  "singleQuote": true,
154
154
  "tabWidth": 2,
155
155
  "trailingComma": "es5",
156
- "arrowParens": "always",
157
- "printWidth": 100
156
+ "arrowParens": "always"
158
157
  }
159
158
  }
@@ -1,9 +0,0 @@
1
- import { FC, InputHTMLAttributes } from 'react';
2
- import { WithStatusProps } from '../../system/HOC';
3
- export declare type BaseInputProps = InputHTMLAttributes<HTMLInputElement> & {
4
- message?: string;
5
- label?: string;
6
- renderInput?: Function;
7
- } & WithStatusProps;
8
- export declare const BaseInput: FC<BaseInputProps>;
9
- export declare const StyledInputField: import("styled-components").StyledComponent<"input", import("styled-components").DefaultTheme, InputHTMLAttributes<HTMLInputElement> & WithStatusProps, never>;
@@ -1,64 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.StyledInputField = exports.BaseInput = void 0;
18
- const jsx_runtime_1 = require("react/jsx-runtime");
19
- const styled_components_1 = __importDefault(require("styled-components"));
20
- const Box_1 = require("../../layout/Box");
21
- const HOC_1 = require("../../system/HOC");
22
- const ThemeProvider_1 = require("../../system/ThemeProvider");
23
- const Text_1 = require("../../typography/Text");
24
- exports.BaseInput = HOC_1.withStatus((_a) => {
25
- var { className, renderInput, message, label, status, name } = _a, inputProps = __rest(_a, ["className", "renderInput", "message", "label", "status", "name"]);
26
- 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)),
27
- !!renderInput && renderInput(Object.assign({ name, status }, inputProps)),
28
- !renderInput && (jsx_runtime_1.jsx(exports.StyledInputField, Object.assign({ className: className, name: name, status: status }, inputProps), void 0)),
29
- !!message && jsx_runtime_1.jsx(InputMessage, Object.assign({ status: status }, { children: message }), void 0)] }), void 0));
30
- });
31
- const InputLabel = styled_components_1.default(Text_1.Text) `
32
- margin-bottom: ${({ theme }) => theme.px.small};
33
- `;
34
- const InputMessage = styled_components_1.default(Text_1.Text) `
35
- color: ${({ theme, status }) => ThemeProvider_1.getStatusColor(theme, status, 'textHelp')};
36
- margin-top: ${({ theme }) => theme.px.small};
37
- `;
38
- const InputContainer = styled_components_1.default(Box_1.Box) `
39
- font-size: ${({ theme }) => theme.fontSize.base};
40
- `;
41
- exports.StyledInputField = styled_components_1.default.input `
42
- background: ${({ theme }) => theme.palette.inputBg};
43
- border: 1px solid ${({ theme }) => theme.palette.inputBg};
44
- border-color: ${({ theme, status }) => ThemeProvider_1.getStatusColor(theme, status, 'inputBg')};
45
- border-radius: ${({ theme }) => theme.radius.small};
46
- box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
47
- color: ${({ theme }) => theme.palette.inputColor};
48
- font-size: ${({ theme }) => theme.fontSize.base};
49
- padding: ${({ theme }) => `${theme.px.small} ${theme.px.base}`};
50
- transition: border-color var(--openfin-ui-globalTransition);
51
-
52
- &:focus {
53
- outline: 0;
54
- border-color: ${({ theme }) => theme.palette.inputFocused};
55
- }
56
-
57
- &:disabled {
58
- cursor: not-allowed;
59
- }
60
-
61
- &:disabled::placeholder {
62
- color: ${({ theme }) => theme.palette.inputDisabled};
63
- }
64
- `;
@@ -1 +0,0 @@
1
- export * from './baseInput';
@@ -1,13 +0,0 @@
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("./baseInput"), exports);
@@ -1 +0,0 @@
1
- export * from './numberInput';
@@ -1,13 +0,0 @@
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("./numberInput"), exports);
@@ -1,3 +0,0 @@
1
- import { FC } from 'react';
2
- import { BaseInputProps } from '../BaseInput';
3
- export declare const NumberInput: FC<BaseInputProps>;
@@ -1,106 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.NumberInput = void 0;
18
- const jsx_runtime_1 = require("react/jsx-runtime");
19
- const react_1 = require("react");
20
- const styled_components_1 = __importDefault(require("styled-components"));
21
- const math_1 = require("../../../lib/math");
22
- const Icon_1 = require("../../elements/Icon");
23
- const Box_1 = require("../../layout/Box");
24
- const BaseInput_1 = require("../BaseInput");
25
- var Direction;
26
- (function (Direction) {
27
- Direction[Direction["Up"] = 1] = "Up";
28
- Direction[Direction["Down"] = -1] = "Down";
29
- })(Direction || (Direction = {}));
30
- const NumberInput = (_a) => {
31
- var { min, max, onChange, step = 1, value = '' } = _a, props = __rest(_a, ["min", "max", "onChange", "step", "value"]);
32
- // Since we are recreating the +/- buttons, we need to capture the value state at this level.
33
- const stepInterval = Number(step);
34
- const [num, setNum] = react_1.useState(value);
35
- react_1.useEffect(() => setNum(value), []);
36
- const takeStep = (direction) => {
37
- const base = num ? Number(num) : 0;
38
- const lower = min ? Number(min) : undefined;
39
- const upper = max ? Number(max) : undefined;
40
- const newNum = math_1.clamp(base + stepInterval * direction, lower, upper);
41
- setNum(newNum);
42
- };
43
- return (jsx_runtime_1.jsx(BaseInput_1.BaseInput, Object.assign({ type: "number" }, props, { renderInput: (_a) => {
44
- var inputProps = __rest(_a, []);
45
- return (jsx_runtime_1.jsx(StyledNumberInput, Object.assign({ onIncrement: () => takeStep(Direction.Up), onDecrement: () => takeStep(Direction.Down), onChange: (event) => {
46
- const { value } = event === null || event === void 0 ? void 0 : event.target;
47
- if (value) {
48
- setNum(Number(value));
49
- }
50
- onChange && onChange(event);
51
- }, min: min, max: max, step: step }, inputProps, { value: num }), void 0));
52
- } }), void 0));
53
- };
54
- exports.NumberInput = NumberInput;
55
- const StyledNumberInput = (_a) => {
56
- var { onIncrement, onDecrement } = _a, props = __rest(_a, ["onIncrement", "onDecrement"]);
57
- return (jsx_runtime_1.jsxs(StyledInputContainer, { children: [jsx_runtime_1.jsx(Input, Object.assign({}, props), void 0),
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
- 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
- };
61
- const StyledInputContainer = styled_components_1.default.div `
62
- position: relative;
63
- overflow: hidden;
64
- border-radius: ${({ theme }) => theme.radius.small};
65
- `;
66
- const ControlContainer = styled_components_1.default(Box_1.Box) `
67
- align-items: center;
68
- position: absolute;
69
- right: 1px;
70
- top: 1px;
71
- gap: 1px;
72
- height: calc(100% - 2px);
73
- border-radius: ${({ theme }) => `0 ${theme.radius.small} ${theme.radius.small} 0`};
74
- overflow: hidden;
75
-
76
- pointer-events: ${({ disabled }) => (disabled ? 'none' : undefined)};
77
- `;
78
- const ArrowControl = styled_components_1.default(Box_1.Box) `
79
- cursor: pointer;
80
- background: ${({ theme }) => theme.palette.inputDisabled};
81
- padding: 0 ${({ theme }) => theme.px.xsmall};
82
- user-select: none;
83
- height: 50%;
84
- align-items: center;
85
- justify-content: center;
86
-
87
- color: ${({ disabled, theme }) => disabled ? theme.palette.textHelp : theme.palette.textDefault};
88
-
89
- &:hover {
90
- background: ${({ theme }) => theme.palette.inputFocused};
91
- }
92
-
93
- &:active {
94
- background: ${({ theme }) => theme.palette.inputColor};
95
- }
96
- `;
97
- const Input = styled_components_1.default(BaseInput_1.StyledInputField) `
98
- appearance: textfield;
99
- padding-right: ${({ theme }) => theme.px.xxxlarge};
100
-
101
- ::-webkit-inner-spin-button,
102
- ::-webkit-outer-spin-button {
103
- appearance: none;
104
- margin: 0;
105
- }
106
- `;
@@ -1,9 +0,0 @@
1
- /**
2
- * Returns a number whose value is limited to the given range.
3
- *
4
- * @param {Number} min The lower boundary of the output range
5
- * @param {Number} max The upper boundary of the output range
6
- * @returns A number in the range [min, max]
7
- * @type Number
8
- */
9
- export declare const clamp: (num: number, min?: number | undefined, max?: number | undefined) => number;
package/dist/lib/math.js DELETED
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.clamp = void 0;
4
- /**
5
- * Returns a number whose value is limited to the given range.
6
- *
7
- * @param {Number} min The lower boundary of the output range
8
- * @param {Number} max The upper boundary of the output range
9
- * @returns A number in the range [min, max]
10
- * @type Number
11
- */
12
- const clamp = (num, min, max) => {
13
- if (min && max) {
14
- return Math.min(Math.max(num, min), max);
15
- }
16
- if (max && !min) {
17
- return Math.min(num, max);
18
- }
19
- if (min && !max) {
20
- return Math.max(num, min);
21
- }
22
- return num;
23
- };
24
- exports.clamp = clamp;