@openfin/ui-library 0.1.11 → 0.1.12-alpha.1620307785
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/README.md +109 -147
- package/dist/components/elements/Badge/badge.js +1 -1
- package/dist/components/elements/Icon/icon.d.ts +2 -1
- package/dist/components/elements/Loader/index.d.ts +1 -0
- package/dist/components/elements/Loader/index.js +13 -0
- package/dist/components/elements/Loader/loader.d.ts +4 -0
- package/dist/components/elements/Loader/loader.js +25 -0
- package/dist/components/input/BaseInput/baseInput.d.ts +6 -2
- package/dist/components/input/BaseInput/baseInput.js +5 -4
- package/dist/components/input/NumberInput/numberInput.d.ts +13 -2
- package/dist/components/input/NumberInput/numberInput.js +11 -10
- package/dist/components/input/TextInput/textInput.d.ts +6 -2
- package/dist/components/input/TextInput/textInput.js +5 -16
- package/dist/components/system/HOC/index.d.ts +0 -7
- package/dist/components/system/HOC/index.js +0 -23
- package/dist/components/system/ThemeProvider/lib/constants.d.ts +0 -2
- package/dist/components/system/ThemeProvider/lib/constants.js +1 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +11 -11
- /package/dist/components/{list → layout}/DefinitionList/definitionList.d.ts +0 -0
- /package/dist/components/{list → layout}/DefinitionList/definitionList.js +0 -0
- /package/dist/components/{list → layout}/DefinitionList/index.d.ts +0 -0
- /package/dist/components/{list → layout}/DefinitionList/index.js +0 -0
package/README.md
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
# OpenFin UI Library
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> React component library for OpenFin Workspace products – Informed by [Spatial](https://www.figma.com/file/0Y3pKZj0tJWuleF12h5Sua/Spatial---Components).
|
|
4
|
+
|
|
5
|
+
**Storybook:** [openfin-ui.netlify.com](https://openfin-ui.netlify.com) (pw: pizza)
|
|
6
|
+
**NPM Package:** [@openfin/ui-library](https://www.npmjs.com/package/@openfin/ui-library)
|
|
4
7
|
|
|
5
8
|
[](https://app.netlify.com/sites/openfin-ui/deploys)
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## What is this for?
|
|
12
|
+
|
|
13
|
+
**TL;DR** – Use this library and write less CSS.
|
|
14
|
+
|
|
15
|
+
This is an opinionated React component library, which aims to provide the basic building blocks that you can use in any OpenFin environment. It was built w/ our [Spatial Design System](https://www.figma.com/file/0Y3pKZj0tJWuleF12h5Sua/Spatial---Components) in mind, so it should always reflect OpenFin's latest branding and designs.
|
|
6
16
|
|
|
7
17
|
## Installation
|
|
8
18
|
|
|
@@ -23,101 +33,140 @@ $ yarn add @openfin/ui-library
|
|
|
23
33
|
$ yarn add @openfin/ui-library@v1.0.1
|
|
24
34
|
```
|
|
25
35
|
|
|
26
|
-
##
|
|
36
|
+
## Usage
|
|
27
37
|
|
|
28
|
-
|
|
38
|
+
### ThemeProvider
|
|
29
39
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
# Make sure yalc is installed globally
|
|
34
|
-
$ npm i yalc -g
|
|
40
|
+
`ThemeProvider` is the component that provides theme information to the `ui-library` components nested deeply within your application. Make sure to include this above your application so your components will be styled properly.
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
```javascript
|
|
43
|
+
import { ThemeProvider } from '@openfin/ui-library';
|
|
44
|
+
import MyApp from 'some/cool/place';
|
|
39
45
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
const MyCoolAppContainer = () => (
|
|
47
|
+
<ThemeProvider>
|
|
48
|
+
<MyApp />
|
|
49
|
+
</ThemeProvider>
|
|
50
|
+
);
|
|
43
51
|
```
|
|
44
52
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
### 2. Working with yalc
|
|
53
|
+
### Basic Usage
|
|
48
54
|
|
|
49
|
-
|
|
55
|
+
```javascript
|
|
56
|
+
import { Box, H1, Icon, TextInput } from '@openfin/ui-library';
|
|
50
57
|
|
|
51
|
-
|
|
58
|
+
export const MyApp = () => (
|
|
59
|
+
<Box flexDirection="column">
|
|
60
|
+
<H1>
|
|
61
|
+
<Icon icon="OpenFinIcon" /> Cool heading
|
|
62
|
+
</H1>
|
|
52
63
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
<TextInput placeholder="Cool stuff goes here" />
|
|
65
|
+
</Box>
|
|
66
|
+
);
|
|
56
67
|
```
|
|
57
68
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
- Storybook does not pick up changes after a `yalc push` and must be restarted
|
|
69
|
+
**View the [Full Component Docs](./src/components) for more usage info.**
|
|
61
70
|
|
|
62
|
-
|
|
71
|
+
### Extending Components
|
|
63
72
|
|
|
64
|
-
|
|
73
|
+
Whenever possible, it is prefereable to use the components as-is. However – using [styled-components](https://styled-components.com/docs), it is very easy. Try using the following guiding principles when doing so:
|
|
65
74
|
|
|
66
|
-
|
|
75
|
+
- Familiarize yourself w/ the `theme` prop, and use it whenever possible.
|
|
76
|
+
- Avoid hard-coded pixel values.
|
|
77
|
+
- Don't _ever_ use hard-coded color values.
|
|
67
78
|
|
|
68
79
|
```javascript
|
|
69
|
-
import {
|
|
70
|
-
import
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
<
|
|
74
|
-
<
|
|
75
|
-
|
|
80
|
+
import { Box, Text } from '@openfin/ui-library';
|
|
81
|
+
import styled from 'styled-components';
|
|
82
|
+
|
|
83
|
+
export const MyCoolComponent = () => (
|
|
84
|
+
<Container flexDirection="column">
|
|
85
|
+
<ImportantText>How cool is this?</ImportantText>
|
|
86
|
+
<Text weight="bold">Super cool</Text>
|
|
87
|
+
</Container>
|
|
76
88
|
);
|
|
89
|
+
|
|
90
|
+
const Container = styled(Box)`
|
|
91
|
+
background: ${({ theme }) => theme.palette.background6};
|
|
92
|
+
border-radius: ${({ theme }) => theme.radius.small};
|
|
93
|
+
margin: ${({ theme }) => `${theme.px.small} 0 ${theme.px.base}`};
|
|
94
|
+
`;
|
|
95
|
+
|
|
96
|
+
const ImportantText = styled(Text)`
|
|
97
|
+
color: ${({ theme }) => theme.palette.statusWarning};
|
|
98
|
+
cursor: pointer;
|
|
99
|
+
font-weight: ${({ theme }) => theme.fontWeight.bold};
|
|
100
|
+
`;
|
|
77
101
|
```
|
|
78
102
|
|
|
79
|
-
##
|
|
103
|
+
## Contributing
|
|
104
|
+
|
|
105
|
+
### Open a pull request 😎
|
|
80
106
|
|
|
81
|
-
|
|
107
|
+
Pull requests are a great way to express an idea or need, if it's easier to "show" instead of "tell", go for it, propose a change!
|
|
108
|
+
|
|
109
|
+
Also keep in mind, UI Library is a home of centralized common components, **used by several products**. It's reasonable to expect PRs may spark conversations about the **essence of the change** and it's benefits and impact across the application ecosystem.
|
|
110
|
+
|
|
111
|
+
Meaning: While there are no hard rules about what belongs in _our_ library, if a change is too opinionated or too specialized, it may make sense to leave it out. **A library that does less, is a lot easier to know and work with**.
|
|
112
|
+
|
|
113
|
+
### Storybook
|
|
82
114
|
|
|
83
|
-
|
|
115
|
+
Great for exploring and experimenting with UI Library components. It's also used for [testing our components](https://storybook.js.org/docs/react/workflows/unit-testing).
|
|
84
116
|
|
|
85
117
|
```bash
|
|
118
|
+
# Run it locally
|
|
86
119
|
$ yarn storybook
|
|
87
120
|
```
|
|
88
121
|
|
|
89
|
-
###
|
|
90
|
-
|
|
91
|
-
Great for a quick look at the latest build, [check it out](https://openfin-ui.netlify.com)
|
|
92
|
-
|
|
93
|
-
## UI Lib @ Codesandbox.io
|
|
122
|
+
### Codesandbox.io
|
|
94
123
|
|
|
95
124
|
Great for developer experimentation without all of the overhead.
|
|
96
125
|
|
|
97
126
|
The sandbox is currently **private**, request access and [give it a try](https://codesandbox.io/s/openfin-ui-library-39y7c).
|
|
98
127
|
|
|
99
|
-
|
|
128
|
+
### Working locally w/ other apps
|
|
100
129
|
|
|
101
|
-
|
|
102
|
-
|
|
130
|
+
Sometimes you may need to work on the `ui-library` alongside your own application. We use [yalc](https://www.npmjs.com/package/yalc) for this. It solves a few problems that `yarn link` creates, and it's pretty intuitive.
|
|
131
|
+
|
|
132
|
+
#### 1. Install and setup yalc
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# Make sure yalc is installed globally
|
|
136
|
+
$ npm i yalc -g
|
|
137
|
+
|
|
138
|
+
# Set up yalc in ui-library
|
|
139
|
+
$ cd ui-library/
|
|
140
|
+
$ yalc publish
|
|
141
|
+
|
|
142
|
+
# Add local ui-library package to your app
|
|
143
|
+
$ cd ../myCoolApp/
|
|
144
|
+
$ yalc add @openfin/ui-library
|
|
103
145
|
```
|
|
104
146
|
|
|
105
|
-
|
|
147
|
+
This links your local copy of UI Library to your app using symlinks and `package.json`.
|
|
148
|
+
|
|
149
|
+
#### 2. Working with yalc
|
|
150
|
+
|
|
151
|
+
Once you're setup, subsequent changes in UI Library can be propagated across easily.
|
|
106
152
|
|
|
107
|
-
|
|
153
|
+
After making changes in `ui-library`, run `yarn build && yalc push`. This will apply a version bump to the local yalc package respository. It will also update the package in your app directory, but you will most likely need to restart any development servers to see the changes.
|
|
108
154
|
|
|
109
155
|
```sh
|
|
110
|
-
|
|
111
|
-
|
|
156
|
+
# push updates from ui-library side to your app
|
|
157
|
+
$ yarn build && yalc push
|
|
112
158
|
```
|
|
113
159
|
|
|
114
|
-
|
|
160
|
+
#### Known Issues
|
|
115
161
|
|
|
116
|
-
|
|
162
|
+
- Storybook does not pick up changes after a `yalc push` and must be restarted
|
|
117
163
|
|
|
118
|
-
|
|
164
|
+
### Linting
|
|
119
165
|
|
|
120
|
-
|
|
166
|
+
```sh
|
|
167
|
+
# Husky runs this command automatically before pushing
|
|
168
|
+
$ yarn git:pre-push
|
|
169
|
+
```
|
|
121
170
|
|
|
122
171
|
## Compiling the Library
|
|
123
172
|
|
|
@@ -133,6 +182,12 @@ Extending base config used by `tsc` when bundling the library for a new release.
|
|
|
133
182
|
|
|
134
183
|
Extending base config used by `Storybook` to quiet some extraneous warnings.
|
|
135
184
|
|
|
185
|
+
## Testing
|
|
186
|
+
|
|
187
|
+
```sh
|
|
188
|
+
yarn test
|
|
189
|
+
```
|
|
190
|
+
|
|
136
191
|
## Versioning & Releasing
|
|
137
192
|
|
|
138
193
|
### 1. Create a release branch
|
|
@@ -166,96 +221,3 @@ Once your release branch is merged into main, you should now create a release th
|
|
|
166
221
|
- Enter a description that includes all feature ticket numbers that were included since the previous release. Don't worry, you can always go back and edit it later.
|
|
167
222
|
|
|
168
223
|
This triggers a Github Action to automatically build the latest version of the `ui-library` and package it for remote installation. Check the status of this task within this repo's actions tab.
|
|
169
|
-
|
|
170
|
-
## Components
|
|
171
|
-
|
|
172
|
-
### Controls
|
|
173
|
-
|
|
174
|
-
- [Button](./src/components/controls/Button)
|
|
175
|
-
- [Icon](./src/components/controls/Icon)
|
|
176
|
-
- [Input](./src/components/input/Input)
|
|
177
|
-
- [Toggle](./src/components/controls/Toggle)
|
|
178
|
-
- [Badge](./src/components/controls/Badge)
|
|
179
|
-
|
|
180
|
-
### Layout
|
|
181
|
-
|
|
182
|
-
- [Box](./src/components/layout/Box)
|
|
183
|
-
|
|
184
|
-
### List
|
|
185
|
-
|
|
186
|
-
- [DefinitionList](./src/components/list/DefinitionList)
|
|
187
|
-
|
|
188
|
-
### System
|
|
189
|
-
|
|
190
|
-
- [GlobalStyles](./src/components/system/GlobalStyles)
|
|
191
|
-
- [ThemeProvider](./src/components/system/ThemeProvider)
|
|
192
|
-
- [Themes](./src/components/system/ThemeProvider/themes) (included OpenFin Themes)
|
|
193
|
-
|
|
194
|
-
### [Typography](./src/components/typography)
|
|
195
|
-
|
|
196
|
-
- Text
|
|
197
|
-
- Heading
|
|
198
|
-
|
|
199
|
-
## [Hooks](./src/hooks)
|
|
200
|
-
|
|
201
|
-
- useMediaQuery
|
|
202
|
-
- useLayoutMediaQuery
|
|
203
|
-
- useColorScheme
|
|
204
|
-
- useTheme
|
|
205
|
-
|
|
206
|
-
## [Mixins](./src/components/system/ThemeProvider/lib/mixins.ts)
|
|
207
|
-
|
|
208
|
-
CSS fragments that you can include in any styled component
|
|
209
|
-
|
|
210
|
-
- `${Mixins.noSelect}`
|
|
211
|
-
- `${Mixins.textOverflow}`
|
|
212
|
-
- `${Mixins.scrollbar.base}`
|
|
213
|
-
- `${Mixins.scrollbar.small}`
|
|
214
|
-
|
|
215
|
-
## Variants
|
|
216
|
-
|
|
217
|
-
### What are variants?
|
|
218
|
-
|
|
219
|
-
Variants as a concept is shared with the Design team and [Spatial](https://www.figma.com/file/0Y3pKZj0tJWuleF12h5Sua/Spatial) and it's a way of describing the _variations_ of a given component.
|
|
220
|
-
|
|
221
|
-
**In Figma**, variants are represented as a matrix of options mapped / instrumented into the design itself.
|
|
222
|
-
|
|
223
|
-
**In UI Library**, variants are represented as a matrix of component props key:values mapped / instrumented into Styled Component css partials.
|
|
224
|
-
|
|
225
|
-
This isn't a new idea, or proprietary to Figma, but it is a built-in first class construct in that software. It's **not** built into the Styled Components as a first class construct, we are creating it here in the UI Library as a novel way to mirror that visual mapping in component builds. It's syntactic sugar, an opinion for working with fragments of style using Styled Components.
|
|
226
|
-
|
|
227
|
-
_It may be slightly more verbose with a bit of initial cognitive cost to represent component variations this way._ Let's commit to this pattern for now, to see it at scale, "in the wild". And let's also commit to continuing to evaluate it's usefulness. The goal is to offer a **semantic symmetry with design and build** that hopefuly translates to more consistent and stable products over a longer timeline.
|
|
228
|
-
|
|
229
|
-
### Can I see an example of variants?
|
|
230
|
-
|
|
231
|
-
Yes! [Button](./src/components/Button), [Icon](./src/components/Icon), and [Toggle](./src/components/Toggle) all implement variants in the UI Library mirroring the variants in Figma.
|
|
232
|
-
|
|
233
|
-
### How does it work?
|
|
234
|
-
|
|
235
|
-
```tsx
|
|
236
|
-
// component.variants.ts
|
|
237
|
-
export const variants = {
|
|
238
|
-
propName: {
|
|
239
|
-
propValueA: css`
|
|
240
|
-
/* CSS... */
|
|
241
|
-
color: red;
|
|
242
|
-
`,
|
|
243
|
-
propValueB: css`
|
|
244
|
-
/* CSS... */
|
|
245
|
-
color: blue;
|
|
246
|
-
`,
|
|
247
|
-
},
|
|
248
|
-
};
|
|
249
|
-
|
|
250
|
-
// component.tsx
|
|
251
|
-
const Component = styled.div<{ propName: string }>`
|
|
252
|
-
/* Injects a CSS Partial matching prop name -> value */
|
|
253
|
-
${getVariantCSS(variants, 'propName')};
|
|
254
|
-
`;
|
|
255
|
-
|
|
256
|
-
// Component with red text
|
|
257
|
-
<Component someProp="propValueA" />
|
|
258
|
-
|
|
259
|
-
// Component with blue text
|
|
260
|
-
<Component someProp="propValueB" />
|
|
261
|
-
```
|
|
@@ -8,8 +8,9 @@ export declare type PropsWithChild = {
|
|
|
8
8
|
icon?: never;
|
|
9
9
|
children: ReactNode;
|
|
10
10
|
};
|
|
11
|
-
export declare type
|
|
11
|
+
export declare type IconSizeProps = {
|
|
12
12
|
size?: IconSizeType;
|
|
13
13
|
containerSize?: IconSizeType;
|
|
14
14
|
};
|
|
15
|
+
export declare type IconProps = HTMLAttributes<HTMLDivElement> & (PropsWithIcon | PropsWithChild) & IconSizeProps;
|
|
15
16
|
export declare const Icon: import("styled-components").StyledComponent<({ icon, children, size, containerSize, ...props }: IconProps) => JSX.Element, import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './loader';
|
|
@@ -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("./loader"), exports);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
import { IconSizeProps } from '../Icon';
|
|
3
|
+
export declare type LoaderProps = IconSizeProps & HTMLAttributes<HTMLDivElement>;
|
|
4
|
+
export declare const Loader: import("styled-components").StyledComponent<({ ...props }: LoaderProps) => JSX.Element, import("styled-components").DefaultTheme, IconSizeProps & HTMLAttributes<HTMLDivElement>, never>;
|
|
@@ -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
|
+
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.Loader = void 0;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
20
|
+
const Icon_1 = require("../Icon");
|
|
21
|
+
exports.Loader = styled_components_1.default((_a) => {
|
|
22
|
+
var props = __rest(_a, []);
|
|
23
|
+
return (jsx_runtime_1.jsx(Icon_1.Icon, Object.assign({}, props, { children: jsx_runtime_1.jsx("svg", Object.assign({ width: "100%", height: "100%", viewBox: "0 0 38 38", xmlns: "http://www.w3.org/2000/svg", stroke: "currentColor" }, { children: jsx_runtime_1.jsx("g", Object.assign({ fill: "none", fillRule: "evenodd" }, { children: jsx_runtime_1.jsxs("g", Object.assign({ transform: "translate(1 1)", strokeWidth: "2" }, { children: [jsx_runtime_1.jsx("circle", { strokeOpacity: ".5", cx: "18", cy: "18", r: "18" }, void 0),
|
|
24
|
+
jsx_runtime_1.jsx("path", Object.assign({ d: "M36 18c0-9.94-8.06-18-18-18" }, { children: jsx_runtime_1.jsx("animateTransform", { attributeName: "transform", type: "rotate", from: "0 18 18", to: "360 18 18", dur: "1s", repeatCount: "indefinite" }, void 0) }), void 0)] }), void 0) }), void 0) }), void 0) }), void 0));
|
|
25
|
+
}) ``;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
|
2
2
|
import { WithStatusProps } from '../../system/HOC';
|
|
3
3
|
export declare type BaseInputProps = InputHTMLAttributes<HTMLInputElement> & {
|
|
4
4
|
message?: string;
|
|
5
5
|
label?: string;
|
|
6
6
|
renderInput?: Function;
|
|
7
7
|
} & WithStatusProps;
|
|
8
|
-
export declare const BaseInput:
|
|
8
|
+
export declare const BaseInput: import("react").ForwardRefExoticComponent<InputHTMLAttributes<HTMLInputElement> & {
|
|
9
|
+
message?: string | undefined;
|
|
10
|
+
label?: string | undefined;
|
|
11
|
+
renderInput?: Function | undefined;
|
|
12
|
+
} & WithStatusProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
9
13
|
export declare const StyledInputField: import("styled-components").StyledComponent<"input", import("styled-components").DefaultTheme, InputHTMLAttributes<HTMLInputElement> & WithStatusProps, never>;
|
|
@@ -16,18 +16,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.StyledInputField = exports.BaseInput = void 0;
|
|
18
18
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
const react_1 = require("react");
|
|
19
20
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
20
21
|
const Box_1 = require("../../layout/Box");
|
|
21
|
-
const HOC_1 = require("../../system/HOC");
|
|
22
22
|
const ThemeProvider_1 = require("../../system/ThemeProvider");
|
|
23
23
|
const Text_1 = require("../../typography/Text");
|
|
24
|
-
exports.BaseInput =
|
|
24
|
+
exports.BaseInput = react_1.forwardRef((_a, ref) => {
|
|
25
25
|
var { className, renderInput, message, label, status, name } = _a, inputProps = __rest(_a, ["className", "renderInput", "message", "label", "status", "name"]);
|
|
26
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
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)),
|
|
28
|
+
!renderInput && (jsx_runtime_1.jsx(exports.StyledInputField, Object.assign({ className: className, name: name, status: status }, inputProps, { ref: ref }), void 0)),
|
|
29
29
|
!!message && jsx_runtime_1.jsx(InputMessage, Object.assign({ status: status }, { children: message }), void 0)] }), void 0));
|
|
30
30
|
});
|
|
31
|
+
exports.BaseInput.displayName = 'BaseInput';
|
|
31
32
|
const InputLabel = styled_components_1.default(Text_1.Text) `
|
|
32
33
|
margin-bottom: ${({ theme }) => theme.px.small};
|
|
33
34
|
`;
|
|
@@ -43,7 +44,7 @@ exports.StyledInputField = styled_components_1.default.input `
|
|
|
43
44
|
border: 1px solid ${({ theme }) => theme.palette.inputBg};
|
|
44
45
|
border-color: ${({ theme, status }) => ThemeProvider_1.getStatusColor(theme, status, 'inputBg')};
|
|
45
46
|
border-radius: ${({ theme }) => theme.radius.small};
|
|
46
|
-
box-shadow:
|
|
47
|
+
box-shadow: ${({ theme }) => theme.shadow.base};
|
|
47
48
|
color: ${({ theme }) => theme.palette.inputColor};
|
|
48
49
|
font-size: ${({ theme }) => theme.fontSize.base};
|
|
49
50
|
padding: ${({ theme }) => `${theme.px.small} ${theme.px.base}`};
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ChangeEventHandler } from 'react';
|
|
2
2
|
import { BaseInputProps } from '../BaseInput';
|
|
3
|
-
|
|
3
|
+
interface NumberInputProps extends Omit<BaseInputProps, 'value'> {
|
|
4
|
+
min?: number;
|
|
5
|
+
max?: number;
|
|
6
|
+
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
7
|
+
/**
|
|
8
|
+
* @default 1
|
|
9
|
+
*/
|
|
10
|
+
step?: number;
|
|
11
|
+
value?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const NumberInput: import("react").ForwardRefExoticComponent<NumberInputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
14
|
+
export {};
|
|
@@ -27,12 +27,12 @@ var Direction;
|
|
|
27
27
|
Direction[Direction["Up"] = 1] = "Up";
|
|
28
28
|
Direction[Direction["Down"] = -1] = "Down";
|
|
29
29
|
})(Direction || (Direction = {}));
|
|
30
|
-
|
|
31
|
-
var { min, max, onChange, step = 1, value
|
|
30
|
+
exports.NumberInput = react_1.forwardRef((_a, ref) => {
|
|
31
|
+
var { min, max, onChange, step = 1, value } = _a, props = __rest(_a, ["min", "max", "onChange", "step", "value"]);
|
|
32
32
|
// Since we are recreating the +/- buttons, we need to capture the value state at this level.
|
|
33
33
|
const stepInterval = Number(step);
|
|
34
|
-
const [num, setNum] = react_1.useState(value);
|
|
35
|
-
react_1.useEffect(() => setNum(value), []);
|
|
34
|
+
const [num, setNum] = react_1.useState(Number(value));
|
|
35
|
+
react_1.useEffect(() => setNum(Number(value)), []);
|
|
36
36
|
const takeStep = (direction) => {
|
|
37
37
|
const base = num ? Number(num) : 0;
|
|
38
38
|
const lower = min ? Number(min) : undefined;
|
|
@@ -42,7 +42,7 @@ const NumberInput = (_a) => {
|
|
|
42
42
|
};
|
|
43
43
|
return (jsx_runtime_1.jsx(BaseInput_1.BaseInput, Object.assign({ type: "number" }, props, { renderInput: (_a) => {
|
|
44
44
|
var inputProps = __rest(_a, []);
|
|
45
|
-
return (jsx_runtime_1.jsx(StyledNumberInput, Object.assign({ onIncrement: () => takeStep(Direction.Up), onDecrement: () => takeStep(Direction.Down), onChange: (event) => {
|
|
45
|
+
return (jsx_runtime_1.jsx(StyledNumberInput, Object.assign({ ref: ref, onIncrement: () => takeStep(Direction.Up), onDecrement: () => takeStep(Direction.Down), onChange: (event) => {
|
|
46
46
|
const { value } = event === null || event === void 0 ? void 0 : event.target;
|
|
47
47
|
if (value) {
|
|
48
48
|
setNum(Number(value));
|
|
@@ -50,14 +50,15 @@ const NumberInput = (_a) => {
|
|
|
50
50
|
onChange && onChange(event);
|
|
51
51
|
}, min: min, max: max, step: step }, inputProps, { value: num }), void 0));
|
|
52
52
|
} }), void 0));
|
|
53
|
-
};
|
|
54
|
-
exports.NumberInput = NumberInput;
|
|
55
|
-
const StyledNumberInput = (_a) => {
|
|
53
|
+
});
|
|
54
|
+
exports.NumberInput.displayName = 'NumberInput';
|
|
55
|
+
const StyledNumberInput = react_1.forwardRef((_a, ref) => {
|
|
56
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),
|
|
57
|
+
return (jsx_runtime_1.jsxs(StyledInputContainer, { children: [jsx_runtime_1.jsx(Input, Object.assign({ ref: ref }, props), void 0),
|
|
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
62
|
const StyledInputContainer = styled_components_1.default.div `
|
|
62
63
|
position: relative;
|
|
63
64
|
overflow: hidden;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { BaseInputProps } from '../BaseInput';
|
|
3
3
|
export declare type TextInputProps = BaseInputProps;
|
|
4
|
-
export declare const TextInput:
|
|
4
|
+
export declare const TextInput: import("react").ForwardRefExoticComponent<import("react").InputHTMLAttributes<HTMLInputElement> & {
|
|
5
|
+
message?: string | undefined;
|
|
6
|
+
label?: string | undefined;
|
|
7
|
+
renderInput?: Function | undefined;
|
|
8
|
+
} & import("../../system/HOC").WithStatusProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -1,21 +1,10 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.TextInput = void 0;
|
|
15
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
16
6
|
const BaseInput_1 = require("../BaseInput");
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
exports.TextInput = TextInput;
|
|
7
|
+
exports.TextInput = react_1.forwardRef((props, ref) => {
|
|
8
|
+
return jsx_runtime_1.jsx(BaseInput_1.BaseInput, Object.assign({ ref: ref, type: "text" }, props), void 0);
|
|
9
|
+
});
|
|
10
|
+
exports.TextInput.displayName = 'TextInput';
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import { ComponentType, FC } from 'react';
|
|
2
1
|
export declare type StatusType = 'success' | 'warning' | 'critical' | 'active';
|
|
3
2
|
export declare type WithStatusProps = {
|
|
4
3
|
status?: StatusType;
|
|
5
4
|
};
|
|
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>;
|
|
@@ -1,25 +1,2 @@
|
|
|
1
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
2
|
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;
|
|
@@ -161,9 +161,7 @@ exports.Radius = {
|
|
|
161
161
|
* Note: This does not include any `text-shadow`
|
|
162
162
|
*/
|
|
163
163
|
exports.Shadow = {
|
|
164
|
-
[exports.Size.
|
|
165
|
-
[exports.Size.base]: `0 0 ${exports.UnitPx.large} rgba(0,0,0,0.5)`,
|
|
166
|
-
[exports.Size.large]: `0 0 ${exports.UnitPx.xlarge} rgba(0,0,0,0.5)`,
|
|
164
|
+
[exports.Size.base]: `0 4px 4px rgba(0, 0, 0, 0.25)`,
|
|
167
165
|
};
|
|
168
166
|
const fonts = [
|
|
169
167
|
'Inter',
|
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,12 @@ 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/elements/Loader';
|
|
5
6
|
export * from './components/input/RawInput';
|
|
6
7
|
export * from './components/input/TextInput';
|
|
7
8
|
export * from './components/input/NumberInput';
|
|
8
9
|
export * from './components/layout/Box';
|
|
9
|
-
export * from './components/
|
|
10
|
+
export * from './components/layout/DefinitionList';
|
|
10
11
|
export * from './components/system/GlobalStyles';
|
|
11
12
|
export * from './components/system/ThemeProvider';
|
|
12
13
|
export * from './components/typography/Heading';
|
package/dist/index.js
CHANGED
|
@@ -27,11 +27,12 @@ __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/elements/Loader"), exports);
|
|
30
31
|
__exportStar(require("./components/input/RawInput"), exports);
|
|
31
32
|
__exportStar(require("./components/input/TextInput"), exports);
|
|
32
33
|
__exportStar(require("./components/input/NumberInput"), exports);
|
|
33
34
|
__exportStar(require("./components/layout/Box"), exports);
|
|
34
|
-
__exportStar(require("./components/
|
|
35
|
+
__exportStar(require("./components/layout/DefinitionList"), exports);
|
|
35
36
|
__exportStar(require("./components/system/GlobalStyles"), exports);
|
|
36
37
|
__exportStar(require("./components/system/ThemeProvider"), exports);
|
|
37
38
|
__exportStar(require("./components/typography/Heading"), 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.
|
|
4
|
+
"version": "0.1.12-alpha.1620307785",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"repository": "github:openfin/ui-library",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"dist/**/*"
|
|
11
11
|
],
|
|
12
12
|
"engines": {
|
|
13
|
-
"node": "
|
|
13
|
+
"node": "12",
|
|
14
14
|
"yarn": "1"
|
|
15
15
|
},
|
|
16
16
|
"license": "MIT",
|
|
@@ -19,19 +19,19 @@
|
|
|
19
19
|
"tinycolor2": "^1.4.2"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"styled-components": "^5.2.
|
|
22
|
+
"styled-components": "^5.2.3"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@babel/cli": "^7.13.10",
|
|
26
26
|
"@babel/core": "^7.13.10",
|
|
27
27
|
"@babel/preset-env": "^7.13.10",
|
|
28
28
|
"@babel/preset-typescript": "^7.13.0",
|
|
29
|
-
"@storybook/addon-actions": "^6.2.
|
|
30
|
-
"@storybook/addon-essentials": "^6.2.
|
|
31
|
-
"@storybook/addon-links": "^6.2.
|
|
32
|
-
"@storybook/node-logger": "^6.2.
|
|
29
|
+
"@storybook/addon-actions": "^6.2.9",
|
|
30
|
+
"@storybook/addon-essentials": "^6.2.9",
|
|
31
|
+
"@storybook/addon-links": "^6.2.9",
|
|
32
|
+
"@storybook/node-logger": "^6.2.9",
|
|
33
33
|
"@storybook/preset-create-react-app": "^3.1.7",
|
|
34
|
-
"@storybook/react": "^6.2.
|
|
34
|
+
"@storybook/react": "^6.2.9",
|
|
35
35
|
"@testing-library/jest-dom": "^5.11.9",
|
|
36
36
|
"@testing-library/react": "^11.2.3",
|
|
37
37
|
"@testing-library/user-event": "^12.6.2",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@types/node": "^14.14.34",
|
|
43
43
|
"@types/react": "^17.0.3",
|
|
44
44
|
"@types/react-dom": "^17.0.2",
|
|
45
|
-
"@types/styled-components": "^5.1.
|
|
45
|
+
"@types/styled-components": "^5.1.9",
|
|
46
46
|
"@types/tinycolor2": "^1.4.2",
|
|
47
47
|
"@typescript-eslint/eslint-plugin": "^4.17.0",
|
|
48
48
|
"@typescript-eslint/parser": "^4.17.0",
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
"react-scripts": "4.0.1",
|
|
62
62
|
"rimraf": "^3.0.2",
|
|
63
63
|
"storybook-addon-performance": "^0.15.2",
|
|
64
|
-
"styled-components": "^5.2.
|
|
64
|
+
"styled-components": "^5.2.3",
|
|
65
65
|
"stylelint": "^13.12.0",
|
|
66
66
|
"stylelint-config-recommended": "^4.0.0",
|
|
67
67
|
"stylelint-config-styled-components": "^0.1.1",
|
|
68
68
|
"stylelint-processor-styled-components": "^1.10.0",
|
|
69
69
|
"tsconfig-paths-webpack-plugin": "^3.3.0",
|
|
70
|
-
"typescript": "^4.
|
|
70
|
+
"typescript": "^4.2.4",
|
|
71
71
|
"web-vitals": "^1.1.0"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|