@openfin/ui-library 0.1.2 → 0.1.3-alpha.1616639854
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.
- package/dist/components/controls/Toggle/toggle.js +4 -3
- package/dist/components/elements/Icon/openfin/WorkspaceIcon.js +4 -4
- package/dist/components/input/RawInput/index.d.ts +1 -0
- package/dist/components/input/{Input → RawInput}/index.js +1 -1
- package/dist/components/input/RawInput/rawInput.d.ts +6 -0
- package/dist/components/input/{Input/input.js → RawInput/rawInput.js} +4 -4
- package/dist/components/input/TextInput/textInput.d.ts +5 -2
- package/dist/components/input/TextInput/textInput.js +40 -6
- package/dist/components/system/GlobalStyles/globalStyles.js +0 -4
- package/dist/components/system/HOC/index.d.ts +11 -0
- package/dist/components/system/HOC/index.js +25 -0
- package/dist/components/system/ThemeProvider/lib/helpers.d.ts +6 -0
- package/dist/components/system/ThemeProvider/lib/helpers.js +20 -1
- package/dist/components/system/ThemeProvider/lib/types.d.ts +3 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +6 -2
- package/dist/components/input/Input/index.d.ts +0 -1
- package/dist/components/input/Input/input.d.ts +0 -6
|
@@ -18,7 +18,7 @@ exports.Toggle = void 0;
|
|
|
18
18
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
19
|
const react_1 = require("react");
|
|
20
20
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
21
|
-
const
|
|
21
|
+
const RawInput_1 = require("../../input/RawInput");
|
|
22
22
|
const Box_1 = require("../../layout/Box");
|
|
23
23
|
const Toggle = (_a) => {
|
|
24
24
|
var { id, label, labelSide = 'right', type = 'checkbox', onChange = () => { } } = _a, inputProps = __rest(_a, ["id", "label", "labelSide", "type", "onChange"]);
|
|
@@ -49,7 +49,8 @@ const InputContainer = styled_components_1.default(Box_1.Box) `
|
|
|
49
49
|
border-radius: calc(0.5 * var(--px-toggle));
|
|
50
50
|
|
|
51
51
|
background: ${({ isChecked, theme }) => isChecked ? theme.palette.brandPrimary : theme.palette.inputBg};
|
|
52
|
-
transition: background var(--global-transition)
|
|
52
|
+
transition: background var(--global-transition),
|
|
53
|
+
border-color var(--global-transition);
|
|
53
54
|
|
|
54
55
|
&:focus-within {
|
|
55
56
|
border-color: ${({ theme }) => theme.palette.inputFocused};
|
|
@@ -69,7 +70,7 @@ const ToggleKnob = styled_components_1.default.button `
|
|
|
69
70
|
transition: left var(--global-transition);
|
|
70
71
|
pointer-events: none; /* Allow pass-thru for native input */
|
|
71
72
|
`;
|
|
72
|
-
const ToggleInput = styled_components_1.default(
|
|
73
|
+
const ToggleInput = styled_components_1.default(RawInput_1.RawInput) `
|
|
73
74
|
position: absolute;
|
|
74
75
|
top: 0;
|
|
75
76
|
left: 0;
|
|
@@ -18,9 +18,9 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
18
18
|
*/
|
|
19
19
|
const WorkspaceIcon = (_a) => {
|
|
20
20
|
var { color = 'currentColor' } = _a, props = __rest(_a, ["color"]);
|
|
21
|
-
return (jsx_runtime_1.jsxs("svg", Object.assign({ width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, props, { children: [jsx_runtime_1.jsx("
|
|
22
|
-
jsx_runtime_1.jsx("
|
|
23
|
-
jsx_runtime_1.jsx("
|
|
24
|
-
jsx_runtime_1.jsx("
|
|
21
|
+
return (jsx_runtime_1.jsxs("svg", Object.assign({ width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, props, { children: [jsx_runtime_1.jsx("path", { d: "M6.73811 2.8125H3.53137C3.13442 2.8125 2.81262 3.1343 2.81262 3.53125V7.51204C2.81262 7.909 3.13442 8.23079 3.53137 8.23079H6.73811C7.13506 8.23079 7.45686 7.909 7.45686 7.51204V3.53125C7.45686 3.1343 7.13506 2.8125 6.73811 2.8125Z", fill: color }, void 0),
|
|
22
|
+
jsx_runtime_1.jsx("path", { d: "M12.1565 6.26758H8.94971C8.75123 6.26758 8.59033 6.42848 8.59033 6.62696V11.3818C8.59033 11.5803 8.75123 11.7412 8.94971 11.7412H12.1565C12.3549 11.7412 12.5158 11.5803 12.5158 11.3818V6.62696C12.5158 6.42848 12.3549 6.26758 12.1565 6.26758Z", stroke: color, strokeWidth: "0.718753" }, void 0),
|
|
23
|
+
jsx_runtime_1.jsx("path", { d: "M12.1564 2.8125H8.94971C8.55275 2.8125 8.23096 3.1343 8.23096 3.53125V4.41587C8.23096 4.81283 8.55275 5.13463 8.94971 5.13463H12.1564C12.5534 5.13463 12.8752 4.81283 12.8752 4.41587V3.53125C12.8752 3.1343 12.5534 2.8125 12.1564 2.8125Z", fill: color }, void 0),
|
|
24
|
+
jsx_runtime_1.jsx("path", { d: "M6.73798 9.00488H3.53125C3.1343 9.00488 2.8125 9.32668 2.8125 9.72364V11.3823C2.8125 11.7793 3.1343 12.1011 3.53125 12.1011H6.73798C7.13494 12.1011 7.45674 11.7793 7.45674 11.3823V9.72364C7.45674 9.32668 7.13494 9.00488 6.73798 9.00488Z", fill: color }, void 0)] }), void 0));
|
|
25
25
|
};
|
|
26
26
|
exports.WorkspaceIcon = WorkspaceIcon;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './rawInput';
|
|
@@ -10,4 +10,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./
|
|
13
|
+
__exportStar(require("./rawInput"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
|
2
|
+
export declare type RawInputProps = InputHTMLAttributes<HTMLInputElement>;
|
|
3
|
+
/**
|
|
4
|
+
* Unstyled input extended by other components
|
|
5
|
+
*/
|
|
6
|
+
export declare const RawInput: import("styled-components").StyledComponent<"input", import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.RawInput = void 0;
|
|
7
7
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
8
|
/**
|
|
9
|
-
* Unstyled
|
|
9
|
+
* Unstyled input extended by other components
|
|
10
10
|
*/
|
|
11
|
-
exports.
|
|
12
|
-
exports.
|
|
11
|
+
exports.RawInput = styled_components_1.default.input ``;
|
|
12
|
+
exports.RawInput.displayName = 'RawInput';
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { FC, InputHTMLAttributes } from 'react';
|
|
2
|
-
export declare type TextInputProps = InputHTMLAttributes<HTMLInputElement
|
|
3
|
-
|
|
2
|
+
export declare type TextInputProps = InputHTMLAttributes<HTMLInputElement> & {
|
|
3
|
+
message?: string;
|
|
4
|
+
label?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const TextInput: FC;
|
|
@@ -17,14 +17,48 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.TextInput = void 0;
|
|
18
18
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
19
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
exports.TextInput =
|
|
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, rest = __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 }, rest), 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) `
|
|
26
42
|
background: ${({ theme }) => theme.palette.inputBg};
|
|
27
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};
|
|
28
46
|
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
|
29
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(--global-transition);
|
|
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
|
+
}
|
|
30
64
|
`;
|
|
@@ -22,10 +22,6 @@ exports.GlobalStyles = styled_components_1.createGlobalStyle `
|
|
|
22
22
|
box-sizing: border-box;
|
|
23
23
|
margin: 0;
|
|
24
24
|
padding: 0;
|
|
25
|
-
/**
|
|
26
|
-
* Smooths light-on-dark Fonts on Mac
|
|
27
|
-
*/
|
|
28
|
-
-webkit-font-smoothing: antialiased;
|
|
29
25
|
/**
|
|
30
26
|
* Prevent browser auto-weighting
|
|
31
27
|
* @link https://css-tricks.com/almanac/properties/f/font-synthesis/
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ComponentType, FC } from 'react';
|
|
2
|
+
export declare type StatusType = 'success' | 'warning' | 'critical' | 'active';
|
|
3
|
+
export declare type WithStatusProps = {
|
|
4
|
+
status?: StatusType;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* withStatus HOC
|
|
8
|
+
* Takes a component and applies the status prop to it.
|
|
9
|
+
* @returns Instantiated component w/ status and other props applied.
|
|
10
|
+
*/
|
|
11
|
+
export declare const withStatus: <P extends object>(Component: ComponentType<P>) => FC<P & WithStatusProps>;
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.withStatus = void 0;
|
|
15
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
|
+
/**
|
|
17
|
+
* withStatus HOC
|
|
18
|
+
* Takes a component and applies the status prop to it.
|
|
19
|
+
* @returns Instantiated component w/ status and other props applied.
|
|
20
|
+
*/
|
|
21
|
+
const withStatus = (Component) => function withStatus(_a) {
|
|
22
|
+
var { status } = _a, props = __rest(_a, ["status"]);
|
|
23
|
+
return jsx_runtime_1.jsx(Component, Object.assign({ status: status }, props), void 0);
|
|
24
|
+
};
|
|
25
|
+
exports.withStatus = withStatus;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DefaultTheme, StyledProps } from 'styled-components';
|
|
2
|
+
import { StatusType } from '../../HOC';
|
|
2
3
|
export declare type ComponentVariants = {
|
|
3
4
|
[key: string]: {
|
|
4
5
|
[key: string]: any;
|
|
@@ -17,3 +18,8 @@ export declare const getVariantCSS: (variants: ComponentVariants, variantProp: s
|
|
|
17
18
|
export declare const getFontFaces: ({ theme }: {
|
|
18
19
|
theme: DefaultTheme;
|
|
19
20
|
}) => import("styled-components").FlattenSimpleInterpolation;
|
|
21
|
+
/**
|
|
22
|
+
* Retrive the correct palette value based on the provided status type.
|
|
23
|
+
* Falls back to optionally provided palette key, then to 'inherit'.
|
|
24
|
+
*/
|
|
25
|
+
export declare const getStatusColor: (theme: DefaultTheme, status?: StatusType | undefined, defaultKey?: "background1" | "background2" | "background3" | "background4" | "background5" | "background6" | "brandPrimary" | "brandSecondary" | "inputBg" | "inputColor" | "inputPlaceholder" | "inputDisabled" | "inputFocused" | "statusSuccess" | "statusWarning" | "statusCritical" | "statusActive" | "textDefault" | "textHelp" | "textInactive" | undefined) => string;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getFontFaces = exports.getVariantCSS = void 0;
|
|
6
|
+
exports.getStatusColor = exports.getFontFaces = exports.getVariantCSS = void 0;
|
|
7
7
|
const font_face_base64_1 = __importDefault(require("./font-face-base64"));
|
|
8
8
|
const font_face_cdn_1 = __importDefault(require("./font-face-cdn"));
|
|
9
9
|
/**
|
|
@@ -29,3 +29,22 @@ const getFontFaces = ({ theme }) => {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
exports.getFontFaces = getFontFaces;
|
|
32
|
+
/**
|
|
33
|
+
* Retrive the correct palette value based on the provided status type.
|
|
34
|
+
* Falls back to optionally provided palette key, then to 'inherit'.
|
|
35
|
+
*/
|
|
36
|
+
const getStatusColor = (theme, status, defaultKey) => {
|
|
37
|
+
switch (status) {
|
|
38
|
+
case 'active':
|
|
39
|
+
return theme.palette.statusActive;
|
|
40
|
+
case 'critical':
|
|
41
|
+
return theme.palette.statusCritical;
|
|
42
|
+
case 'warning':
|
|
43
|
+
return theme.palette.statusWarning;
|
|
44
|
+
case 'success':
|
|
45
|
+
return theme.palette.statusSuccess;
|
|
46
|
+
default:
|
|
47
|
+
return defaultKey ? theme.palette[defaultKey] : 'inherit';
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
exports.getStatusColor = getStatusColor;
|
|
@@ -15,16 +15,17 @@ export declare type TransitionType = keyof typeof Transition;
|
|
|
15
15
|
export declare type TypographyType = keyof typeof Typography;
|
|
16
16
|
export declare type UnitPxType = keyof typeof UnitPx;
|
|
17
17
|
export declare type UnitType = keyof typeof Unit;
|
|
18
|
+
export declare type PaletteType = Record<keyof typeof Palette, string>;
|
|
18
19
|
export declare type ThemeSet = {
|
|
19
20
|
light: DefaultTheme;
|
|
20
21
|
dark: DefaultTheme;
|
|
21
22
|
};
|
|
22
23
|
export declare type ThemePaletteSet = {
|
|
23
24
|
light: {
|
|
24
|
-
palette:
|
|
25
|
+
palette: PaletteType;
|
|
25
26
|
};
|
|
26
27
|
dark: {
|
|
27
|
-
palette:
|
|
28
|
+
palette: PaletteType;
|
|
28
29
|
};
|
|
29
30
|
};
|
|
30
31
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ export * from './components/controls/Button';
|
|
|
2
2
|
export * from './components/controls/Toggle';
|
|
3
3
|
export * from './components/elements/Badge';
|
|
4
4
|
export * from './components/elements/Icon';
|
|
5
|
-
export * from './components/input/
|
|
5
|
+
export * from './components/input/RawInput';
|
|
6
|
+
export * from './components/input/TextInput';
|
|
6
7
|
export * from './components/layout/Box';
|
|
7
8
|
export * from './components/list/DefinitionList';
|
|
8
9
|
export * from './components/system/GlobalStyles';
|
package/dist/index.js
CHANGED
|
@@ -27,7 +27,8 @@ __exportStar(require("./components/controls/Button"), exports);
|
|
|
27
27
|
__exportStar(require("./components/controls/Toggle"), exports);
|
|
28
28
|
__exportStar(require("./components/elements/Badge"), exports);
|
|
29
29
|
__exportStar(require("./components/elements/Icon"), exports);
|
|
30
|
-
__exportStar(require("./components/input/
|
|
30
|
+
__exportStar(require("./components/input/RawInput"), exports);
|
|
31
|
+
__exportStar(require("./components/input/TextInput"), exports);
|
|
31
32
|
__exportStar(require("./components/layout/Box"), exports);
|
|
32
33
|
__exportStar(require("./components/list/DefinitionList"), exports);
|
|
33
34
|
__exportStar(require("./components/system/GlobalStyles"), exports);
|
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfin/ui-library",
|
|
3
3
|
"description": "OpenFin UI Component Library",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3-alpha.1616639854",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"repository": "github:openfin/ui-library",
|
|
8
|
+
"homepage": "https://openfin-ui.netlify.app",
|
|
7
9
|
"files": [
|
|
8
10
|
"dist/**/*"
|
|
9
11
|
],
|
|
10
12
|
"license": "MIT",
|
|
11
|
-
"
|
|
13
|
+
"peerDependencies": {
|
|
12
14
|
"@modulz/radix-icons": "^4.0.0",
|
|
13
15
|
"styled-components": "^5.2.1"
|
|
14
16
|
},
|
|
@@ -17,6 +19,7 @@
|
|
|
17
19
|
"@babel/core": "^7.13.10",
|
|
18
20
|
"@babel/preset-env": "^7.13.10",
|
|
19
21
|
"@babel/preset-typescript": "^7.13.0",
|
|
22
|
+
"@modulz/radix-icons": "^4.0.0",
|
|
20
23
|
"@storybook/addon-actions": "^6.1.21",
|
|
21
24
|
"@storybook/addon-essentials": "^6.1.21",
|
|
22
25
|
"@storybook/addon-links": "^6.1.21",
|
|
@@ -48,6 +51,7 @@
|
|
|
48
51
|
"react-dom": "^17.0.1",
|
|
49
52
|
"react-scripts": "4.0.1",
|
|
50
53
|
"rimraf": "^3.0.2",
|
|
54
|
+
"styled-components": "^5.2.1",
|
|
51
55
|
"stylelint": "^13.12.0",
|
|
52
56
|
"stylelint-config-recommended": "^4.0.0",
|
|
53
57
|
"stylelint-config-styled-components": "^0.1.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './input';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { InputHTMLAttributes } from 'react';
|
|
2
|
-
export declare type InputProps = InputHTMLAttributes<HTMLInputElement>;
|
|
3
|
-
/**
|
|
4
|
-
* Unstyled Input extended by other components
|
|
5
|
-
*/
|
|
6
|
-
export declare const Input: import("styled-components").StyledComponent<"input", import("styled-components").DefaultTheme, {}, never>;
|