genesys-react-components 1.0.6 → 1.1.0-devengage-3187-id-prop.758

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/package.json CHANGED
@@ -1,59 +1,59 @@
1
1
  {
2
- "name": "genesys-react-components",
3
- "version": "1.0.6",
4
- "description": "A React component library containing standardized form elements.",
5
- "type": "module",
6
- "types": "build/index.d.ts",
7
- "main": "./build/index.js",
8
- "exports": {
9
- "require": "./src/index.ts",
10
- "default": "./build/index.js"
11
- },
12
- "files": [
13
- "build",
14
- "src"
15
- ],
16
- "scripts": {
17
- "build": "rm -rf build && rollup -c rollup.config.js",
18
- "localbuild": "npm i && npm run build && rm -rf node_modules",
19
- "test": "echo \"0/0 tests passed. That's technically a perfect score. Keep up the great work!\""
20
- },
21
- "repository": {
22
- "type": "git",
23
- "url": "git+ssh://git@github.com/purecloudlabs/genesys-react-components.git"
24
- },
25
- "author": "Genesys",
26
- "license": "MIT",
27
- "bugs": {
28
- "url": "https://github.com/purecloudlabs/genesys-react-components/issues"
29
- },
30
- "homepage": "https://purecloudlabs.github.io/genesys-react-components",
31
- "devDependencies": {
32
- "@rollup/plugin-commonjs": "^21.0.1",
33
- "@rollup/plugin-node-resolve": "^13.0.6",
34
- "@types/react": "^16",
35
- "react": "^16",
36
- "react-dom": "^16",
37
- "rollup": "^2.60.2",
38
- "rollup-plugin-peer-deps-external": "^2.2.4",
39
- "rollup-plugin-postcss": "^4.0.2",
40
- "rollup-plugin-typescript2": "^0.31.1",
41
- "sass": "^1.44.0",
42
- "typescript": "^4.5.2",
43
- "uuid": "^9.0.0"
44
- },
45
- "peerDependencies": {
46
- "genesys-dev-icons": "^1.5.0",
47
- "moment": "^2.30.1",
48
- "postcss": "^8.5.3",
49
- "react": ">=16",
50
- "react-dom": ">=16",
51
- "react-syntax-highlighter": "^15.5.0",
52
- "uuid": "^9.0.0"
53
- },
54
- "dependencies": {
55
- "moment": "^2.30.1",
56
- "postcss": "^8.5.3",
57
- "react-syntax-highlighter": "^15.6.1"
58
- }
59
- }
2
+ "name": "genesys-react-components",
3
+ "version": "1.1.0-devengage-3187-id-prop.758",
4
+ "description": "A React component library containing standardized form elements.",
5
+ "type": "module",
6
+ "types": "build/index.d.ts",
7
+ "main": "./build/index.js",
8
+ "exports": {
9
+ "require": "./src/index.ts",
10
+ "default": "./build/index.js"
11
+ },
12
+ "files": [
13
+ "build",
14
+ "src"
15
+ ],
16
+ "scripts": {
17
+ "build": "rm -rf build && rollup -c rollup.config.js",
18
+ "localbuild": "npm i && npm run build && rm -rf node_modules",
19
+ "test": "echo \"0/0 tests passed. That's technically a perfect score. Keep up the great work!\""
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+ssh://git@github.com/purecloudlabs/genesys-react-components.git"
24
+ },
25
+ "author": "Genesys",
26
+ "license": "MIT",
27
+ "bugs": {
28
+ "url": "https://github.com/purecloudlabs/genesys-react-components/issues"
29
+ },
30
+ "homepage": "https://purecloudlabs.github.io/genesys-react-components",
31
+ "devDependencies": {
32
+ "@rollup/plugin-commonjs": "^21.0.1",
33
+ "@rollup/plugin-node-resolve": "^13.0.6",
34
+ "@types/react": "^16",
35
+ "react": "^16",
36
+ "react-dom": "^16",
37
+ "rollup": "^2.60.2",
38
+ "rollup-plugin-peer-deps-external": "^2.2.4",
39
+ "rollup-plugin-postcss": "^4.0.2",
40
+ "rollup-plugin-typescript2": "^0.31.1",
41
+ "sass": "^1.44.0",
42
+ "typescript": "^4.5.2",
43
+ "uuid": "^9.0.0"
44
+ },
45
+ "peerDependencies": {
46
+ "genesys-dev-icons": "^1.5.0",
47
+ "moment": "^2.30.1",
48
+ "postcss": "^8.5.3",
49
+ "react": ">=16",
50
+ "react-dom": ">=16",
51
+ "react-syntax-highlighter": "^15.5.0",
52
+ "uuid": "^9.0.0"
53
+ },
54
+ "dependencies": {
55
+ "moment": "^2.30.1",
56
+ "postcss": "^8.5.3",
57
+ "react-syntax-highlighter": "^15.6.1"
58
+ }
59
+ }
@@ -1,9 +1,11 @@
1
1
  import React, { useState } from 'react';
2
2
  import { GenesysDevIcon, GenesysDevIcons } from 'genesys-dev-icons';
3
3
 
4
+ import { BaseComponentProps } from '..';
5
+
4
6
  import './AlertBlock.scss';
5
7
 
6
- interface IProps {
8
+ interface IProps extends BaseComponentProps {
7
9
  title?: string;
8
10
  alertType?: 'info' | 'success' | 'critical' | 'warning' | 'toast';
9
11
  collapsible?: boolean;
@@ -59,6 +61,7 @@ export default function AlertBlock(props: IProps) {
59
61
  //TODO: remove the card fence classes and build a proper collapser
60
62
  return (
61
63
  <div
64
+ id={props.id}
62
65
  className={`alert-container${props.indentation && props.indentation > 0 ? ` indent-${props.indentation}` : ''} ${
63
66
  props.className || ''
64
67
  }`}
@@ -4,6 +4,7 @@ import { PrismAsync as SyntaxHighlighter } from 'react-syntax-highlighter';
4
4
  import { vscDarkPlus } from 'react-syntax-highlighter/dist/cjs/styles/prism/index.js';
5
5
 
6
6
  import CopyButton from '../copybutton/CopyButton';
7
+ import { BaseComponentProps } from '..';
7
8
 
8
9
  import './CodeFence.scss';
9
10
 
@@ -13,7 +14,7 @@ declare global {
13
14
  }
14
15
  }
15
16
 
16
- interface IProps {
17
+ interface IProps extends BaseComponentProps {
17
18
  value: string;
18
19
  noCollapse?: boolean;
19
20
  noHeader?: boolean;
@@ -43,7 +44,7 @@ export default function CodeFence(props: IProps) {
43
44
  const disableHighlighting = props.disableSyntaxHighlighting || props.value.length > 100000;
44
45
 
45
46
  return (
46
- <div className={classNames.join(' ')}>
47
+ <div id={props.id} className={classNames.join(' ')}>
47
48
  {props.noHeader || typeof props.value !== 'string' ? (
48
49
  ''
49
50
  ) : (
@@ -1,10 +1,12 @@
1
1
  import { GenesysDevIcon, GenesysDevIcons } from 'genesys-dev-icons';
2
2
  import React, { useState } from 'react';
3
+
3
4
  import Tooltip from '../tooltip/Tooltip';
5
+ import { BaseComponentProps } from '..';
4
6
 
5
7
  import './CopyButton.scss';
6
8
 
7
- interface IProps {
9
+ interface IProps extends BaseComponentProps {
8
10
  copyText: string;
9
11
  className?: string;
10
12
  tooltipPosition?: 'top' | 'right' | 'bottom' | 'left';
@@ -33,7 +35,7 @@ export default function CopyButton(props: IProps) {
33
35
  return (
34
36
  <React.Fragment>
35
37
  <Tooltip isShowing={copyState} text="Copied" position={props.tooltipPosition}>
36
- <button type="button" className={buttonClasses.join(' ')} onClick={copyCode} onMouseOut={loseFocus}>
38
+ <button id={props.id} type="button" className={buttonClasses.join(' ')} onClick={copyCode} onMouseOut={loseFocus}>
37
39
  <GenesysDevIcon icon={GenesysDevIcons.AppCopy} />
38
40
  </button>
39
41
  </Tooltip>
@@ -1,14 +1,16 @@
1
1
  /* eslint-disable react-hooks/exhaustive-deps */
2
+ import React, { useEffect, useState, ReactNode } from 'react';
2
3
  import { GenesysDevIcon, GenesysDevIcons } from 'genesys-dev-icons';
4
+ import moment from 'moment';
5
+
3
6
  import DxTextbox from '../dxtextbox/DxTextbox';
4
7
  import DxToggle from '../dxtoggle/DxToggle';
5
- import moment from 'moment';
6
- import React, { useEffect, useState, ReactNode } from 'react';
7
8
  import CopyButton from '../copybutton/CopyButton';
8
- import { DataTableRow } from '..';
9
+ import { BaseComponentProps, DataTableRow } from '..';
10
+
9
11
  import './DataTable.scss';
10
12
 
11
- interface IProps {
13
+ interface IProps extends BaseComponentProps {
12
14
  rows: DataTableRow[];
13
15
  headerRow?: DataTableRow;
14
16
  className?: string;
@@ -409,7 +411,7 @@ export default function DataTable(props: IProps) {
409
411
  <div className="filter-toggle" style={{ visibility: isFilterable ? 'visible' : 'hidden' }}>
410
412
  <GenesysDevIcon icon={GenesysDevIcons.AppFilter} onClick={() => setIsFilterOpen(!isFilterOpen)} />
411
413
  </div>
412
- <table className={tableClassName} cellSpacing="0">
414
+ <table id={props.id} className={tableClassName} cellSpacing="0">
413
415
  {thead}
414
416
  <tbody>
415
417
  {rows.map((row, i) => {
@@ -1,5 +1,6 @@
1
1
  import { GenesysDevIcon, GenesysDevIcons } from 'genesys-dev-icons';
2
2
  import React, { useState } from 'react';
3
+
3
4
  import { DxAccordionProps } from '..';
4
5
 
5
6
  import './DxAccordion.scss';
@@ -36,7 +37,7 @@ export default function DxAccordion(props: DxAccordionProps) {
36
37
  if (props.headingIcon) icon = <GenesysDevIcon icon={props.headingIcon} className="heading-icon" />;
37
38
 
38
39
  return (
39
- <div id={props.containerId || undefined} className={`dx-accordion${props.className ? ' ' + props.className : ''}`}>
40
+ <div id={props.id || props.containerId || undefined} className={`dx-accordion${props.className ? ' ' + props.className : ''}`}>
40
41
  <div className="accordion-heading" style={style} onClick={() => setIsOpen(!isOpen)}>
41
42
  <span className="accordion-heading__left">
42
43
  {icon} {props.title}
@@ -1,12 +1,18 @@
1
1
  import React from 'react';
2
2
 
3
+ import { BaseComponentProps } from '..';
4
+
3
5
  import './DxAccordionGroup.scss';
4
6
 
5
- interface IProps {
7
+ interface IProps extends BaseComponentProps {
6
8
  children: React.ReactNode;
7
9
  className?: string;
8
10
  }
9
11
 
10
12
  export default function DxAccordionGroup(props: IProps) {
11
- return <div className={`dx-accordion-group${props.className ? ' ' + props.className : ''}`}>{props.children}</div>;
13
+ return (
14
+ <div id={props.id} className={`dx-accordion-group${props.className ? ' ' + props.className : ''}`}>
15
+ {props.children}
16
+ </div>
17
+ );
12
18
  }
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
- import { VoidEventCallback } from '..';
2
+
3
+ import { BaseComponentProps, VoidEventCallback } from '..';
3
4
 
4
5
  import './DxButton.scss';
5
6
 
6
- interface IProps {
7
+ interface IProps extends BaseComponentProps {
7
8
  type?: 'primary' | 'secondary' | 'link';
8
9
  disabled?: boolean;
9
10
  children?: React.ReactNode;
@@ -34,7 +35,7 @@ export default function DxButton(props: IProps) {
34
35
  };
35
36
 
36
37
  return (
37
- <button className={classNames.join(' ')} type="button" onClick={handleClick} disabled={props.disabled === true}>
38
+ <button id={props.id} className={classNames.join(' ')} type="button" onClick={handleClick} disabled={props.disabled === true}>
38
39
  {props.children}
39
40
  </button>
40
41
  );
@@ -1,9 +1,10 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { CheckedChangedCallback } from '..';
2
+
3
+ import { BaseComponentProps, CheckedChangedCallback } from '..';
3
4
 
4
5
  import './DxCheckbox.scss';
5
6
 
6
- interface IProps {
7
+ interface IProps extends BaseComponentProps {
7
8
  label: string;
8
9
  itemValue: string;
9
10
  description?: string;
@@ -31,7 +32,7 @@ export default function DxCheckbox(props: IProps) {
31
32
  }, [checked]);
32
33
 
33
34
  return (
34
- <label className={`dx-checkbox${props.className ? ' ' + props.className : ''}${props.disabled ? ' disabled' : ''}`}>
35
+ <label id={props.id} className={`dx-checkbox${props.className ? ' ' + props.className : ''}${props.disabled ? ' disabled' : ''}`}>
35
36
  <input
36
37
  type={props.useRadioType ? 'radio' : 'checkbox'}
37
38
  name={props.name}
@@ -1,13 +1,14 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import { v4 as uuid } from 'uuid';
3
- import { DxItemGroupItem, DxItemGroupItemValue, DxItemGroupProps, ItemChangedCallback, ItemGroupChangedCallback } from '..';
3
+
4
+ import { DxItemGroupItem, DxItemGroupItemValue, DxItemGroupProps } from '..';
5
+ import DxLabel from '../dxlabel/DxLabel';
6
+ import DxCheckbox from './DxCheckbox';
4
7
 
5
8
  import './DxItemGroup.scss';
6
9
  import './radiobutton.scss';
7
10
  import './dropdown.scss';
8
11
  import './multiselect.scss';
9
- import DxLabel from '../dxlabel/DxLabel';
10
- import DxCheckbox from './DxCheckbox';
11
12
 
12
13
  export default function DxItemGroup(props: DxItemGroupProps) {
13
14
  const [data, setData] = useState<DxItemGroupItemValue[]>(
@@ -75,7 +76,7 @@ export default function DxItemGroup(props: DxItemGroupProps) {
75
76
  case 'dropdown': {
76
77
  const isMulti = format === 'multiselect';
77
78
  return (
78
- <DxLabel label={title} description={description} className={className}>
79
+ <DxLabel id={props.id} label={title} description={description} className={className}>
79
80
  <div className={`dx-item-group${isMulti ? ' dx-multiselect-group' : ' dx-select-group'}${disabled ? ' disabled' : ''}`}>
80
81
  <select
81
82
  multiple={isMulti}
@@ -102,6 +103,7 @@ export default function DxItemGroup(props: DxItemGroupProps) {
102
103
  default: {
103
104
  return (
104
105
  <DxLabel
106
+ id={props.id}
105
107
  label={title}
106
108
  description={description}
107
109
  className={`dx-item-group${disabled ? ' disabled' : ''}${className ? ' ' + className : ''}`}
@@ -1,9 +1,11 @@
1
1
  import { GenesysDevIcon, GenesysDevIcons } from 'genesys-dev-icons';
2
2
  import React from 'react';
3
3
 
4
+ import { BaseComponentProps } from '..';
5
+
4
6
  import './DxLabel.scss';
5
7
 
6
- interface IProps {
8
+ interface IProps extends BaseComponentProps {
7
9
  label?: string;
8
10
  description?: string;
9
11
  useFieldset?: boolean;
@@ -15,7 +17,7 @@ export default function DxLabel(props: IProps) {
15
17
  const hasLabel = props.label && props.label !== '';
16
18
 
17
19
  const description = props.description ? (
18
- <div className='input-description'>
20
+ <div className="input-description">
19
21
  <GenesysDevIcon icon={GenesysDevIcons.AppInfoSolid} />
20
22
  <span>{props.description}</span>
21
23
  </div>
@@ -24,7 +26,7 @@ export default function DxLabel(props: IProps) {
24
26
  const contents = (
25
27
  <React.Fragment>
26
28
  {' '}
27
- {hasLabel ? <span className='label-text'>{props.label}</span> : undefined}
29
+ {hasLabel ? <span className="label-text">{props.label}</span> : undefined}
28
30
  {props.children}
29
31
  {description}
30
32
  </React.Fragment>
@@ -35,5 +37,9 @@ export default function DxLabel(props: IProps) {
35
37
  if (props.useFieldset) {
36
38
  return <fieldset className={className}>{contents}</fieldset>;
37
39
  }
38
- return <label className={className}>{contents}</label>;
40
+ return (
41
+ <label id={props.id} className={className}>
42
+ {contents}
43
+ </label>
44
+ );
39
45
  }
@@ -4,5 +4,9 @@ import { DxTabPanelProps } from '..';
4
4
  import './DxTabPanel.scss';
5
5
 
6
6
  export default function DxTabPanel(props: DxTabPanelProps) {
7
- return <div className={`dx-tab-panel${props.className ? ' ' + props.className : ''}`}>{props.children}</div>;
7
+ return (
8
+ <div id={props.id} className={`dx-tab-panel${props.className ? ' ' + props.className : ''}`}>
9
+ {props.children}
10
+ </div>
11
+ );
8
12
  }
@@ -7,7 +7,7 @@ export default function DxTabbedContent(props: DxTabbedContentProps) {
7
7
  const [activeTab, setActiveTab] = useState(props.initialTabId || 0);
8
8
 
9
9
  return (
10
- <div className={`dx-tabbed-content${props.className ? ' ' + props.className : ''}`}>
10
+ <div id={props.id} className={`dx-tabbed-content${props.className ? ' ' + props.className : ''}`}>
11
11
  <div className="tab-titles">
12
12
  {React.Children.toArray(props.children).map((child: any, i) => {
13
13
  if (!child) return;
@@ -184,7 +184,7 @@ export default function DxTextbox(props: DxTextboxProps) {
184
184
 
185
185
  // Render
186
186
  return (
187
- <DxLabel label={props.label} description={props.description} className={props.className}>
187
+ <DxLabel id={props.id} label={props.label} description={props.description} className={props.className}>
188
188
  {component}
189
189
  </DxLabel>
190
190
  );
@@ -1,9 +1,10 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import { GenesysDevIcon, GenesysDevIcons } from 'genesys-dev-icons';
3
+
3
4
  import { BooleanChangedCallback, DxToggleProps } from '..';
5
+ import DxLabel from '../dxlabel/DxLabel';
4
6
 
5
7
  import './DxToggle.scss';
6
- import DxLabel from '../dxlabel/DxLabel';
7
8
 
8
9
  export default function DxToggle(props: DxToggleProps) {
9
10
  let initialValue: boolean | undefined = props.value !== undefined ? props.value : props.initialValue;
@@ -45,7 +46,7 @@ export default function DxToggle(props: DxToggleProps) {
45
46
  };
46
47
 
47
48
  return (
48
- <DxLabel label={props.label} description={props.description} className={props.className}>
49
+ <DxLabel id={props.id} label={props.label} description={props.description} className={props.className}>
49
50
  <div aria-checked={getToggleValue()} className={`dx-toggle-container${props.disabled ? ' disabled' : ''}`}>
50
51
  <div className="dx-toggle" onClick={setToggleValue}>
51
52
  {value !== false ? <GenesysDevIcon icon={falseIcon} /> : undefined}
package/src/index.ts CHANGED
@@ -51,6 +51,10 @@ export interface VoidEventCallback {
51
51
  (): void;
52
52
  }
53
53
 
54
+ export interface BaseComponentProps {
55
+ id?: string;
56
+ }
57
+
54
58
  // Item in a DxItemGroup
55
59
  export interface DxItemGroupItem {
56
60
  label: string;
@@ -73,7 +77,7 @@ export interface ItemGroupChangedCallback {
73
77
  (items: DxItemGroupItemValue[]): void;
74
78
  }
75
79
 
76
- export interface DxToggleProps {
80
+ export interface DxToggleProps extends BaseComponentProps {
77
81
  isTriState?: boolean;
78
82
  initialValue?: boolean;
79
83
  value?: boolean;
@@ -88,7 +92,7 @@ export interface DxToggleProps {
88
92
 
89
93
  export type DxTextboxType = 'text' | 'textarea' | 'password' | 'email' | 'date' | 'datetime-local' | 'time' | 'integer' | 'decimal';
90
94
 
91
- export interface DxTextboxProps {
95
+ export interface DxTextboxProps extends BaseComponentProps {
92
96
  initialValue?: string;
93
97
  value?: string;
94
98
  inputType?: DxTextboxType;
@@ -109,19 +113,19 @@ export interface DxTextboxProps {
109
113
  onKeyboardEvent?: { (event: KeyboardEvent): void };
110
114
  }
111
115
 
112
- export interface DxAccordionProps {
116
+ export interface DxAccordionProps extends BaseComponentProps {
117
+ containerId?: string; // Deprecated, use id
113
118
  title: React.ReactNode;
114
119
  children: React.ReactNode;
115
120
  showOpen?: boolean;
116
121
  className?: string;
117
122
  expandTrigger?: any;
118
123
  showOpenTrigger?: any;
119
- containerId?: string;
120
124
  headingIcon?: any;
121
125
  headingColor?: string;
122
126
  }
123
127
 
124
- export interface DxItemGroupProps {
128
+ export interface DxItemGroupProps extends BaseComponentProps {
125
129
  title?: string;
126
130
  description?: string;
127
131
  format: DxItemGroupFormat;
@@ -134,13 +138,13 @@ export interface DxItemGroupProps {
134
138
 
135
139
  export type DxItemGroupFormat = 'checkbox' | 'radio' | 'dropdown' | 'multiselect';
136
140
 
137
- export interface DxTabbedContentProps {
141
+ export interface DxTabbedContentProps extends BaseComponentProps {
138
142
  children: React.ReactNode;
139
143
  initialTabId?: number;
140
144
  className?: string;
141
145
  }
142
146
 
143
- export interface DxTabPanelProps {
147
+ export interface DxTabPanelProps extends BaseComponentProps {
144
148
  title: React.ReactNode;
145
149
  children: React.ReactNode;
146
150
  className?: string;
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
2
 
3
+ import { BaseComponentProps } from '..';
4
+
3
5
  import './LoadingPlaceholder.scss';
4
6
 
5
7
  // SimCity loading messages! https://gist.github.com/erikcox/7e96d031d00d7ecb1a2f
@@ -95,13 +97,13 @@ const MESSAGES = [
95
97
  'Unable to Reveal Current Activity',
96
98
  ];
97
99
 
98
- interface IProps {
100
+ interface IProps extends BaseComponentProps {
99
101
  text?: string;
100
102
  }
101
103
 
102
104
  export default function LoadingPlaceholder(props: IProps) {
103
105
  return (
104
- <div className="loading-placeholder">
106
+ <div id={props.id} className="loading-placeholder">
105
107
  <span className="text">{props.text || MESSAGES[Math.floor(Math.random() * (MESSAGES.length - 1))]}</span>
106
108
  <div></div>
107
109
  <div></div>