genesys-react-components 0.1.0-alpha.1 → 0.1.0-alpha.13
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/LICENSE +21 -0
- package/README.md +111 -0
- package/build/dxaccordion/DxAccordion.d.ts +4 -0
- package/{dist/esm/lib → build}/dxaccordion/DxAccordionGroup.d.ts +8 -7
- package/{dist/cjs/lib → build}/dxbutton/DxButton.d.ts +12 -12
- package/build/dxitemgroup/DxCheckbox.d.ts +17 -0
- package/build/dxitemgroup/DxItemGroup.d.ts +7 -0
- package/{dist/esm/lib → build}/dxlabel/DxLabel.d.ts +11 -11
- package/build/dxtabbedcontent/DxTabPanel.d.ts +4 -0
- package/build/dxtabbedcontent/DxTabbedContent.d.ts +4 -0
- package/build/dxtextbox/DxTextbox.d.ts +4 -0
- package/build/dxtoggle/DxToggle.d.ts +4 -0
- package/build/index.d.ts +98 -0
- package/build/index.js +396 -0
- package/build/index.js.map +1 -0
- package/package.json +27 -35
- package/dist/cjs/index.js +0 -2865
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/lib/dxaccordion/DxAccordion.d.ts +0 -9
- package/dist/cjs/lib/dxaccordion/DxAccordionGroup.d.ts +0 -7
- package/dist/cjs/lib/dxitemgroup/DxItemGroup.d.ts +0 -18
- package/dist/cjs/lib/dxlabel/DxLabel.d.ts +0 -11
- package/dist/cjs/lib/dxtabbedcontent/DxTabPanel.d.ts +0 -8
- package/dist/cjs/lib/dxtabbedcontent/DxTabbedContent.d.ts +0 -8
- package/dist/cjs/lib/dxtextbox/DxTextbox.d.ts +0 -20
- package/dist/cjs/lib/dxtoggle/DxToggle.d.ts +0 -14
- package/dist/cjs/lib/index.d.ts +0 -31
- package/dist/esm/index.js +0 -2854
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/dxaccordion/DxAccordion.d.ts +0 -9
- package/dist/esm/lib/dxbutton/DxButton.d.ts +0 -12
- package/dist/esm/lib/dxitemgroup/DxItemGroup.d.ts +0 -18
- package/dist/esm/lib/dxtabbedcontent/DxTabPanel.d.ts +0 -8
- package/dist/esm/lib/dxtabbedcontent/DxTabbedContent.d.ts +0 -8
- package/dist/esm/lib/dxtextbox/DxTextbox.d.ts +0 -20
- package/dist/esm/lib/dxtoggle/DxToggle.d.ts +0 -14
- package/dist/esm/lib/index.d.ts +0 -31
- package/dist/index.d.ts +0 -101
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Genesys Cloud Services, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Genesys React Components
|
|
2
|
+
|
|
3
|
+
A React component library containing standardized form elements. Check out the live demo and full documenation at https://purecloudlabs.github.io/genesys-react-components/
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm i genesys-react-components
|
|
9
|
+
# install peer dependencies if necessary
|
|
10
|
+
npm i genesys-dev-icons uuid
|
|
11
|
+
|
|
12
|
+
# or
|
|
13
|
+
|
|
14
|
+
yarn add genesys-react-components
|
|
15
|
+
# install peer dependencies if necessary
|
|
16
|
+
yarn add genesys-dev-icons uuid
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import React, { useRef } from 'react';
|
|
23
|
+
import { DxTextbox } from 'genesys-react-components';
|
|
24
|
+
import { GenesysDevIcons } from 'genesys-dev-icons';
|
|
25
|
+
|
|
26
|
+
export default function App() {
|
|
27
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
28
|
+
return (
|
|
29
|
+
<div className='app'>
|
|
30
|
+
<DxTextbox
|
|
31
|
+
label='1000ms debounce (default 300), removes focus on value change via onChange callback'
|
|
32
|
+
placeholder='Focus will clear 1 second after you stop typing'
|
|
33
|
+
icon={GenesysDevIcons.AppZoomZoomRight}
|
|
34
|
+
clearButton={true}
|
|
35
|
+
onChange={(value: string) => {
|
|
36
|
+
console.log('1000ms debouncer triggered, clearing focus', value);
|
|
37
|
+
inputRef.current?.blur();
|
|
38
|
+
}}
|
|
39
|
+
changeDebounceMs={1000}
|
|
40
|
+
inputRef={inputRef}
|
|
41
|
+
onFocus={() => console.log('focus')}
|
|
42
|
+
onBlur={() => console.log('blur')}
|
|
43
|
+
/>
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Building Locally
|
|
50
|
+
|
|
51
|
+
### `genesys-react-components` package
|
|
52
|
+
|
|
53
|
+
In the root of the repo, run:
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
npm i
|
|
57
|
+
npm run build
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
This clears the build folder and rebuilds the package from source using the rollup configuration to produce single-file libraries.
|
|
61
|
+
|
|
62
|
+
When validating the package locally, run `npm link` in the root of this repo to create a local symlink in npm for `genesys-react-components` that points to the locally built package. Take note of the _Error: Invalid hook call_ notice in the troubleshooting section below.
|
|
63
|
+
|
|
64
|
+
### Demo app
|
|
65
|
+
|
|
66
|
+
To build and serve the demo app locally, run:
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
cd app
|
|
70
|
+
yarn install
|
|
71
|
+
yarn start
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
To validate the local instance of the `genesys-react-components` package, run:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
cd app
|
|
78
|
+
# This removes the published dependency and uses npm link to add the local version
|
|
79
|
+
yarn linklib
|
|
80
|
+
yarn start
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Run `yarn unlinklib` to revert to using the latest published version of the package.
|
|
84
|
+
|
|
85
|
+
#### Publishing the demo app
|
|
86
|
+
|
|
87
|
+
Run the following command to publish the demo app to the GitHub Pages site:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
cd app
|
|
91
|
+
yarn unlink
|
|
92
|
+
yarn publish
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Troubleshooting
|
|
96
|
+
|
|
97
|
+
### Error: Invalid hook call
|
|
98
|
+
|
|
99
|
+
The following error may be encountered at runtime while running a React app locally when using `npm link genesys-react-components` to load the local package:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
|
|
103
|
+
1. You might have mismatching versions of React and the renderer (such as React DOM)
|
|
104
|
+
2. You might be breaking the Rules of Hooks
|
|
105
|
+
3. You might have more than one copy of React in the same app
|
|
106
|
+
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The cause of the issue is the first reason. The react-dom dependency is sourced from different locations for the component package and the React app that's using it. The package loads `<thisrepo>/node_modules/react_dom/` but the React app loads `<thisrepo>/app/node_modules/react-dom/` causing them to be different packages even though the loaded versions are identical.
|
|
110
|
+
|
|
111
|
+
The solution is to delete `<thisrepo>/node_modules/` when using `npm link` in a any local React app. It doesn't seem to matter the order of operations as long as the folder is gone before `yarn start` is run to build the React app.
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import './DxAccordionGroup.scss';
|
|
3
|
-
interface IProps {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './DxAccordionGroup.scss';
|
|
3
|
+
interface IProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export default function DxAccordionGroup(props: IProps): JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { VoidEventCallback } from '..';
|
|
3
|
-
import './DxButton.scss';
|
|
4
|
-
interface IProps {
|
|
5
|
-
type?: 'primary' | 'secondary';
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
children?: React.ReactNode;
|
|
8
|
-
className?: string;
|
|
9
|
-
onClick?: VoidEventCallback;
|
|
10
|
-
}
|
|
11
|
-
export default function DxButton(props: IProps): JSX.Element;
|
|
12
|
-
export {};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { VoidEventCallback } from '..';
|
|
3
|
+
import './DxButton.scss';
|
|
4
|
+
interface IProps {
|
|
5
|
+
type?: 'primary' | 'secondary';
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
onClick?: VoidEventCallback;
|
|
10
|
+
}
|
|
11
|
+
export default function DxButton(props: IProps): JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CheckedChangedCallback } from '..';
|
|
3
|
+
import './DxCheckbox.scss';
|
|
4
|
+
interface IProps {
|
|
5
|
+
label: string;
|
|
6
|
+
itemValue: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
checked?: boolean;
|
|
9
|
+
initiallyChecked?: boolean;
|
|
10
|
+
name?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
onCheckChanged?: CheckedChangedCallback;
|
|
13
|
+
useRadioType?: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export default function DxCheckbox(props: IProps): JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DxItemGroupProps } from '..';
|
|
3
|
+
import './DxItemGroup.scss';
|
|
4
|
+
import './radiobutton.scss';
|
|
5
|
+
import './dropdown.scss';
|
|
6
|
+
import './multiselect.scss';
|
|
7
|
+
export default function DxItemGroup(props: DxItemGroupProps): JSX.Element;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import './DxLabel.scss';
|
|
3
|
-
interface IProps {
|
|
4
|
-
label?: string;
|
|
5
|
-
description?: string;
|
|
6
|
-
useFieldset?: boolean;
|
|
7
|
-
className?: string;
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
}
|
|
10
|
-
export default function DxLabel(props: IProps): JSX.Element;
|
|
11
|
-
export {};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './DxLabel.scss';
|
|
3
|
+
interface IProps {
|
|
4
|
+
label?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
useFieldset?: boolean;
|
|
7
|
+
className?: string;
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export default function DxLabel(props: IProps): JSX.Element;
|
|
11
|
+
export {};
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { GenesysDevIcons } from 'genesys-dev-icons';
|
|
3
|
+
import DxAccordion from './dxaccordion/DxAccordion';
|
|
4
|
+
import DxAccordionGroup from './dxaccordion/DxAccordionGroup';
|
|
5
|
+
import DxButton from './dxbutton/DxButton';
|
|
6
|
+
import DxItemGroup from './dxitemgroup/DxItemGroup';
|
|
7
|
+
import DxCheckbox from './dxitemgroup/DxCheckbox';
|
|
8
|
+
import DxLabel from './dxlabel/DxLabel';
|
|
9
|
+
import DxTabbedContent from './dxtabbedcontent/DxTabbedContent';
|
|
10
|
+
import DxTabPanel from './dxtabbedcontent/DxTabPanel';
|
|
11
|
+
import DxTextbox from './dxtextbox/DxTextbox';
|
|
12
|
+
import DxToggle from './dxtoggle/DxToggle';
|
|
13
|
+
export { DxAccordion, DxAccordionGroup, DxButton, DxItemGroup, DxCheckbox, DxLabel, DxTabbedContent, DxTabPanel, DxTextbox, DxToggle };
|
|
14
|
+
export interface StringChangedCallback {
|
|
15
|
+
(value: string): void;
|
|
16
|
+
}
|
|
17
|
+
export interface BooleanChangedCallback {
|
|
18
|
+
(value?: boolean): void;
|
|
19
|
+
}
|
|
20
|
+
export interface CheckedChangedCallback {
|
|
21
|
+
(checked: boolean): void;
|
|
22
|
+
}
|
|
23
|
+
export interface VoidEventCallback {
|
|
24
|
+
(): void;
|
|
25
|
+
}
|
|
26
|
+
export interface DxItemGroupItem {
|
|
27
|
+
label: string;
|
|
28
|
+
value: string;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
isSelected?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface DxItemGroupItemValue {
|
|
33
|
+
item: DxItemGroupItem;
|
|
34
|
+
isSelected: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface ItemChangedCallback {
|
|
37
|
+
(item: DxItemGroupItem, isSelected: boolean): void;
|
|
38
|
+
}
|
|
39
|
+
export interface ItemGroupChangedCallback {
|
|
40
|
+
(items: DxItemGroupItemValue[]): void;
|
|
41
|
+
}
|
|
42
|
+
export interface DxToggleProps {
|
|
43
|
+
isTriState?: boolean;
|
|
44
|
+
initialValue?: boolean;
|
|
45
|
+
value?: boolean;
|
|
46
|
+
label?: string;
|
|
47
|
+
description?: string;
|
|
48
|
+
trueIcon?: GenesysDevIcons;
|
|
49
|
+
falseIcon?: GenesysDevIcons;
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
onChange?: BooleanChangedCallback;
|
|
52
|
+
className?: string;
|
|
53
|
+
}
|
|
54
|
+
export declare type DxTextboxType = 'text' | 'textarea' | 'password' | 'email' | 'date' | 'datetime-local' | 'time' | 'integer' | 'decimal';
|
|
55
|
+
export interface DxTextboxProps {
|
|
56
|
+
initialValue?: string;
|
|
57
|
+
value?: string;
|
|
58
|
+
inputType?: DxTextboxType;
|
|
59
|
+
label?: string;
|
|
60
|
+
description?: string;
|
|
61
|
+
placeholder?: string;
|
|
62
|
+
icon?: GenesysDevIcons;
|
|
63
|
+
clearButton?: boolean;
|
|
64
|
+
onChange?: StringChangedCallback;
|
|
65
|
+
changeDebounceMs?: number;
|
|
66
|
+
inputRef?: React.RefObject<HTMLInputElement>;
|
|
67
|
+
onFocus?: VoidEventCallback;
|
|
68
|
+
onBlur?: VoidEventCallback;
|
|
69
|
+
disabled?: boolean;
|
|
70
|
+
className?: string;
|
|
71
|
+
}
|
|
72
|
+
export interface DxAccordionProps {
|
|
73
|
+
title: React.ReactNode;
|
|
74
|
+
children: React.ReactNode;
|
|
75
|
+
showOpen?: boolean;
|
|
76
|
+
className?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface DxItemGroupProps {
|
|
79
|
+
title?: string;
|
|
80
|
+
description?: string;
|
|
81
|
+
format: DxItemGroupFormat;
|
|
82
|
+
items: DxItemGroupItem[];
|
|
83
|
+
disabled?: boolean;
|
|
84
|
+
className?: string;
|
|
85
|
+
onItemChanged?: ItemChangedCallback;
|
|
86
|
+
onItemsChanged?: ItemGroupChangedCallback;
|
|
87
|
+
}
|
|
88
|
+
export declare type DxItemGroupFormat = 'checkbox' | 'radio' | 'dropdown' | 'multiselect';
|
|
89
|
+
export interface DxTabbedContentProps {
|
|
90
|
+
children: React.ReactNode;
|
|
91
|
+
initialTabId?: number;
|
|
92
|
+
className?: string;
|
|
93
|
+
}
|
|
94
|
+
export interface DxTabPanelProps {
|
|
95
|
+
title: React.ReactNode;
|
|
96
|
+
children: React.ReactNode;
|
|
97
|
+
className?: string;
|
|
98
|
+
}
|