@seeqdev/qomponents 0.0.132 → 0.0.134

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.
Files changed (156) hide show
  1. package/README.md +135 -135
  2. package/dist/Accordion/Accordion.js +8 -8
  3. package/dist/Accordion/Accordion.stories.js +114 -114
  4. package/dist/Accordion/Accordion.test.js +54 -54
  5. package/dist/Accordion/Accordion.types.js +1 -1
  6. package/dist/Accordion/index.js +1 -1
  7. package/dist/Alert/Alert.js +33 -33
  8. package/dist/Alert/Alert.stories.js +51 -51
  9. package/dist/Alert/Alert.test.js +50 -50
  10. package/dist/Alert/Alert.types.d.ts +1 -0
  11. package/dist/Alert/Alert.types.js +1 -1
  12. package/dist/Alert/index.js +1 -1
  13. package/dist/Button/Button.js +91 -91
  14. package/dist/Button/Button.stories.js +99 -99
  15. package/dist/Button/Button.test.js +48 -48
  16. package/dist/Button/Button.types.js +4 -4
  17. package/dist/Button/index.js +1 -1
  18. package/dist/ButtonGroup/ButtonGroup.js +32 -32
  19. package/dist/ButtonGroup/ButtonGroup.stories.js +384 -384
  20. package/dist/ButtonGroup/ButtonGroup.test.js +66 -66
  21. package/dist/ButtonGroup/ButtonGroup.types.d.ts +1 -0
  22. package/dist/ButtonGroup/ButtonGroup.types.js +1 -1
  23. package/dist/ButtonGroup/index.js +1 -1
  24. package/dist/ButtonWithDropdown/ButtonWithDropdown.js +59 -59
  25. package/dist/ButtonWithDropdown/ButtonWithDropdown.stories.js +142 -142
  26. package/dist/ButtonWithDropdown/ButtonWithDropdown.test.js +92 -92
  27. package/dist/ButtonWithDropdown/ButtonWithDropdown.types.d.ts +1 -0
  28. package/dist/ButtonWithDropdown/ButtonWithDropdown.types.js +1 -1
  29. package/dist/ButtonWithDropdown/index.js +1 -1
  30. package/dist/ButtonWithPopover/ButtonWithPopover.js +61 -61
  31. package/dist/ButtonWithPopover/ButtonWithPopover.stories.js +74 -74
  32. package/dist/ButtonWithPopover/ButtonWithPopover.test.js +81 -81
  33. package/dist/ButtonWithPopover/ButtonWithPopover.types.js +1 -1
  34. package/dist/ButtonWithPopover/index.js +1 -1
  35. package/dist/Carousel/Carousel.js +69 -66
  36. package/dist/Carousel/Carousel.js.map +1 -1
  37. package/dist/Carousel/Carousel.stories.js +114 -114
  38. package/dist/Carousel/Carousel.test.js +47 -47
  39. package/dist/Carousel/Carousel.types.d.ts +1 -0
  40. package/dist/Carousel/Carousel.types.js +1 -1
  41. package/dist/Carousel/index.js +1 -1
  42. package/dist/Checkbox/Checkbox.js +25 -25
  43. package/dist/Checkbox/Checkbox.stories.js +33 -33
  44. package/dist/Checkbox/Checkbox.test.js +93 -93
  45. package/dist/Checkbox/Checkbox.types.d.ts +1 -0
  46. package/dist/Checkbox/Checkbox.types.js +1 -1
  47. package/dist/Checkbox/index.js +1 -1
  48. package/dist/Collapse/Collapse.js +14 -17
  49. package/dist/Collapse/Collapse.js.map +1 -1
  50. package/dist/Collapse/Collapse.stories.js +36 -36
  51. package/dist/Collapse/Collapse.test.js +18 -18
  52. package/dist/Collapse/Collapse.types.d.ts +1 -0
  53. package/dist/Collapse/Collapse.types.js +1 -1
  54. package/dist/Collapse/index.js +1 -1
  55. package/dist/Icon/Icon.js +54 -54
  56. package/dist/Icon/Icon.stories.js +46 -46
  57. package/dist/Icon/Icon.test.js +54 -54
  58. package/dist/Icon/Icon.types.d.ts +1 -0
  59. package/dist/Icon/Icon.types.js +15 -15
  60. package/dist/Icon/index.js +1 -1
  61. package/dist/InputGroup/InputGroup.js +31 -31
  62. package/dist/InputGroup/InputGroup.stories.js +167 -167
  63. package/dist/InputGroup/InputGroup.test.js +42 -42
  64. package/dist/InputGroup/InputGroup.types.d.ts +1 -0
  65. package/dist/InputGroup/InputGroup.types.js +1 -1
  66. package/dist/InputGroup/index.js +1 -1
  67. package/dist/Modal/Modal.js +99 -99
  68. package/dist/Modal/Modal.js.map +1 -1
  69. package/dist/Modal/Modal.stories.js +126 -126
  70. package/dist/Modal/Modal.test.js +107 -107
  71. package/dist/Modal/Modal.types.js +1 -1
  72. package/dist/Modal/index.js +1 -1
  73. package/dist/ProgressBar/ProgressBar.js +49 -29
  74. package/dist/ProgressBar/ProgressBar.js.map +1 -1
  75. package/dist/ProgressBar/ProgressBar.stories.js +80 -72
  76. package/dist/ProgressBar/ProgressBar.stories.js.map +1 -1
  77. package/dist/ProgressBar/ProgressBar.test.js +43 -37
  78. package/dist/ProgressBar/ProgressBar.test.js.map +1 -1
  79. package/dist/ProgressBar/ProgressBar.types.d.ts +2 -0
  80. package/dist/ProgressBar/ProgressBar.types.js +1 -1
  81. package/dist/ProgressBar/index.js +1 -1
  82. package/dist/SeeqActionDropdown/SeeqActionDropdown.js +47 -47
  83. package/dist/SeeqActionDropdown/SeeqActionDropdown.stories.js +79 -79
  84. package/dist/SeeqActionDropdown/SeeqActionDropdown.test.js +72 -72
  85. package/dist/SeeqActionDropdown/SeeqActionDropdown.types.d.ts +1 -0
  86. package/dist/SeeqActionDropdown/SeeqActionDropdown.types.js +1 -1
  87. package/dist/SeeqActionDropdown/index.js +1 -1
  88. package/dist/SeeqActionDropdown/variants.js +22 -22
  89. package/dist/Select/Select.js +173 -173
  90. package/dist/Select/Select.stories.js +79 -79
  91. package/dist/Select/Select.test.js +181 -181
  92. package/dist/Select/Select.types.js +1 -1
  93. package/dist/Select/index.js +2 -2
  94. package/dist/Slider/Slider.js +12 -12
  95. package/dist/Slider/Slider.stories.js +57 -57
  96. package/dist/Slider/Slider.test.js +32 -32
  97. package/dist/Slider/Slider.types.d.ts +1 -0
  98. package/dist/Slider/Slider.types.js +1 -1
  99. package/dist/Slider/index.js +1 -1
  100. package/dist/Tabs/Tabs.js +21 -21
  101. package/dist/Tabs/Tabs.stories.js +90 -90
  102. package/dist/Tabs/Tabs.test.js +90 -90
  103. package/dist/Tabs/Tabs.types.d.ts +1 -0
  104. package/dist/Tabs/Tabs.types.js +1 -1
  105. package/dist/Tabs/index.js +1 -1
  106. package/dist/TextArea/TextArea.js +24 -24
  107. package/dist/TextArea/TextArea.stories.js +45 -45
  108. package/dist/TextArea/TextArea.test.js +67 -67
  109. package/dist/TextArea/TextArea.types.d.ts +1 -0
  110. package/dist/TextArea/TextArea.types.js +1 -1
  111. package/dist/TextArea/index.js +1 -1
  112. package/dist/TextField/TextField.js +78 -78
  113. package/dist/TextField/TextField.stories.js +69 -69
  114. package/dist/TextField/TextField.test.js +38 -38
  115. package/dist/TextField/TextField.types.d.ts +1 -0
  116. package/dist/TextField/TextField.types.js +1 -1
  117. package/dist/TextField/index.js +1 -1
  118. package/dist/ToolbarButton/ToolbarButton.js +74 -74
  119. package/dist/ToolbarButton/ToolbarButton.stories.js +93 -93
  120. package/dist/ToolbarButton/ToolbarButton.test.js +92 -92
  121. package/dist/ToolbarButton/ToolbarButton.types.js +1 -1
  122. package/dist/ToolbarButton/index.js +1 -1
  123. package/dist/Tooltip/QTip.stories.js +44 -44
  124. package/dist/Tooltip/QTip.types.js +1 -1
  125. package/dist/Tooltip/QTipPerformance.stories.js +29 -29
  126. package/dist/Tooltip/Qtip.js +167 -167
  127. package/dist/Tooltip/Tooltip.js +35 -35
  128. package/dist/Tooltip/Tooltip.stories.js +31 -31
  129. package/dist/Tooltip/Tooltip.types.d.ts +1 -0
  130. package/dist/Tooltip/Tooltip.types.js +2 -2
  131. package/dist/Tooltip/TooltipPerformance.stories.js +29 -29
  132. package/dist/Tooltip/index.js +2 -2
  133. package/dist/Tooltip/qTip.utilities.js +10 -10
  134. package/dist/example/.eslintrc.cjs +14 -14
  135. package/dist/example/README.md +33 -33
  136. package/dist/example/index.html +13 -13
  137. package/dist/example/package.json +30 -30
  138. package/dist/example/src/ComplexSelectExample.tsx +81 -81
  139. package/dist/example/src/Example.tsx +408 -408
  140. package/dist/example/src/index.css +102 -102
  141. package/dist/example/src/main.tsx +10 -10
  142. package/dist/example/src/vite-env.d.ts +1 -1
  143. package/dist/example/tsconfig.json +33 -33
  144. package/dist/example/tsconfig.node.json +12 -12
  145. package/dist/example/vite.config.ts +12 -12
  146. package/dist/index.esm.js +15266 -7869
  147. package/dist/index.esm.js.map +1 -1
  148. package/dist/index.js +15230 -7833
  149. package/dist/index.js.map +1 -1
  150. package/dist/styles.css +3714 -3709
  151. package/dist/types.js +1 -1
  152. package/dist/utils/browserId.js +28 -28
  153. package/dist/utils/svg.js +19 -19
  154. package/dist/utils/validateStyleDimension.js +13 -13
  155. package/dist/utils/validateStyleDimension.test.js +19 -19
  156. package/package.json +89 -86
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const DEFAULT_TOOL_TIP_DELAY = 500;
2
3
  export declare const tooltipPositions: readonly ["top", "left", "right", "bottom"];
3
4
  export type TooltipPosition = (typeof tooltipPositions)[number];
@@ -1,3 +1,3 @@
1
- export const DEFAULT_TOOL_TIP_DELAY = 500;
2
- export const tooltipPositions = ['top', 'left', 'right', 'bottom'];
1
+ export const DEFAULT_TOOL_TIP_DELAY = 500;
2
+ export const tooltipPositions = ['top', 'left', 'right', 'bottom'];
3
3
  //# sourceMappingURL=Tooltip.types.js.map
@@ -1,30 +1,30 @@
1
- import React from 'react';
2
- import { Tooltip } from './Tooltip';
3
- import Icon from '../Icon';
4
- export default {
5
- title: 'Tooltip',
6
- };
7
- const renderManyTooltips = () => {
8
- const colsCount = 100;
9
- const rowCount = 100;
10
- const rows = [];
11
- const getCols = (rowId) => {
12
- const cols = [];
13
- for (let i = 0; i < colsCount; i++) {
14
- cols.push(React.createElement("td", { key: 'col_' + i + '_row_' + rowId },
15
- React.createElement(Tooltip, { text: `hello there ${i}` },
16
- React.createElement(Icon, { icon: "fc-sun" }))));
17
- }
18
- return cols;
19
- };
20
- for (let i = 0; i < rowCount; i++) {
21
- rows.push(React.createElement("tr", { key: 'row_' + i }, ...getCols(i)));
22
- }
23
- return (React.createElement("table", null,
24
- React.createElement("tbody", null, rows.map((row) => row))));
25
- };
26
- export const TooltipPerformance = () => {
27
- return (React.createElement(React.Fragment, null,
28
- React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4 tw-text-center" }, renderManyTooltips())));
29
- };
1
+ import React from 'react';
2
+ import { Tooltip } from './Tooltip';
3
+ import Icon from '../Icon';
4
+ export default {
5
+ title: 'Tooltip',
6
+ };
7
+ const renderManyTooltips = () => {
8
+ const colsCount = 100;
9
+ const rowCount = 100;
10
+ const rows = [];
11
+ const getCols = (rowId) => {
12
+ const cols = [];
13
+ for (let i = 0; i < colsCount; i++) {
14
+ cols.push(React.createElement("td", { key: 'col_' + i + '_row_' + rowId },
15
+ React.createElement(Tooltip, { text: `hello there ${i}` },
16
+ React.createElement(Icon, { icon: "fc-sun" }))));
17
+ }
18
+ return cols;
19
+ };
20
+ for (let i = 0; i < rowCount; i++) {
21
+ rows.push(React.createElement("tr", { key: 'row_' + i }, ...getCols(i)));
22
+ }
23
+ return (React.createElement("table", null,
24
+ React.createElement("tbody", null, rows.map((row) => row))));
25
+ };
26
+ export const TooltipPerformance = () => {
27
+ return (React.createElement(React.Fragment, null,
28
+ React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4 tw-text-center" }, renderManyTooltips())));
29
+ };
30
30
  //# sourceMappingURL=TooltipPerformance.stories.js.map
@@ -1,3 +1,3 @@
1
- export { Tooltip } from './Tooltip';
2
- export { QTip } from './Qtip';
1
+ export { Tooltip } from './Tooltip';
2
+ export { QTip } from './Qtip';
3
3
  //# sourceMappingURL=index.js.map
@@ -1,11 +1,11 @@
1
- import { DEFAULT_TOOL_TIP_DELAY } from './Tooltip.types';
2
- export const getQTipData = ({ tooltip, tooltipPlacement, isHtmlTooltip, tooltipTestId, tooltipDelay = DEFAULT_TOOL_TIP_DELAY, }) => tooltip
3
- ? {
4
- 'data-qtip-text': tooltip,
5
- 'data-qtip-placement': tooltipPlacement,
6
- 'data-qtip-is-html': isHtmlTooltip,
7
- 'data-qtip-testid': tooltipTestId,
8
- 'data-qtip-delay': tooltipDelay,
9
- }
10
- : undefined;
1
+ import { DEFAULT_TOOL_TIP_DELAY } from './Tooltip.types';
2
+ export const getQTipData = ({ tooltip, tooltipPlacement, isHtmlTooltip, tooltipTestId, tooltipDelay = DEFAULT_TOOL_TIP_DELAY, }) => tooltip
3
+ ? {
4
+ 'data-qtip-text': tooltip,
5
+ 'data-qtip-placement': tooltipPlacement,
6
+ 'data-qtip-is-html': isHtmlTooltip,
7
+ 'data-qtip-testid': tooltipTestId,
8
+ 'data-qtip-delay': tooltipDelay,
9
+ }
10
+ : undefined;
11
11
  //# sourceMappingURL=qTip.utilities.js.map
@@ -1,14 +1,14 @@
1
- module.exports = {
2
- env: { browser: true, es2020: true },
3
- extends: [
4
- 'eslint:recommended',
5
- 'plugin:@typescript-eslint/recommended',
6
- 'plugin:react-hooks/recommended',
7
- ],
8
- parser: '@typescript-eslint/parser',
9
- parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
10
- plugins: ['react-refresh'],
11
- rules: {
12
- 'react-refresh/only-export-components': 'warn',
13
- },
14
- }
1
+ module.exports = {
2
+ env: { browser: true, es2020: true },
3
+ extends: [
4
+ 'eslint:recommended',
5
+ 'plugin:@typescript-eslint/recommended',
6
+ 'plugin:react-hooks/recommended',
7
+ ],
8
+ parser: '@typescript-eslint/parser',
9
+ parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
10
+ plugins: ['react-refresh'],
11
+ rules: {
12
+ 'react-refresh/only-export-components': 'warn',
13
+ },
14
+ }
@@ -1,33 +1,33 @@
1
- <!-- markdownlint-disable-next-line -->
2
- <p align="center">
3
- <img width="150" src="https://seeq.com/sites/default/files/seeq-content/seeq-logo-blue-web-33h.svg" alt="Seeq logo">
4
- </p>
5
- <h1 align="center">qomponents-form example</h1>
6
-
7
- Time to see qomponents in action!
8
-
9
- This is a simple form example that showcases Seeq's qomponents library.
10
-
11
- This application is built using [vite](https://vitejs.dev/).
12
-
13
- ## Installation
14
-
15
- First, be sure to install all dependencies (React, and qomponents):
16
-
17
- ```sh
18
- npm install
19
- ```
20
-
21
- Once you've installed all dependencies you can start up a dev server and observer any changes you make in real-time:
22
-
23
- ```sh
24
- npm run dev
25
- ```
26
-
27
- ## Tip
28
-
29
- All application code can be found in Example.tsx. Check out the source code to learn how to ensure your
30
- components display using the correct theme (green, blue, orange) as well as the correct mode (light or dark).
31
-
32
-
33
-
1
+ <!-- markdownlint-disable-next-line -->
2
+ <p align="center">
3
+ <img width="150" src="https://seeq.com/sites/default/files/seeq-content/seeq-logo-blue-web-33h.svg" alt="Seeq logo">
4
+ </p>
5
+ <h1 align="center">qomponents-form example</h1>
6
+
7
+ Time to see qomponents in action!
8
+
9
+ This is a simple form example that showcases Seeq's qomponents library.
10
+
11
+ This application is built using [vite](https://vitejs.dev/).
12
+
13
+ ## Installation
14
+
15
+ First, be sure to install all dependencies (React, and qomponents):
16
+
17
+ ```sh
18
+ npm install
19
+ ```
20
+
21
+ Once you've installed all dependencies you can start up a dev server and observer any changes you make in real-time:
22
+
23
+ ```sh
24
+ npm run dev
25
+ ```
26
+
27
+ ## Tip
28
+
29
+ All application code can be found in Example.tsx. Check out the source code to learn how to ensure your
30
+ components display using the correct theme (green, blue, orange) as well as the correct mode (light or dark).
31
+
32
+
33
+
@@ -1,13 +1,13 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>qomponents form example</title>
8
- </head>
9
- <body>
10
- <div id="root"></div>
11
- <script type="module" src="/src/main.tsx"></script>
12
- </body>
13
- </html>
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>qomponents form example</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>
@@ -1,30 +1,30 @@
1
- {
2
- "name": "example",
3
- "private": true,
4
- "version": "0.0.0",
5
- "type": "module",
6
- "scripts": {
7
- "dev": "vite",
8
- "build": "tsc && vite build",
9
- "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
10
- "preview": "vite preview"
11
- },
12
- "dependencies": {
13
- "@fortawesome/fontawesome-free": "^6.4.0",
14
- "@seeqdev/qomponents": "0.0.72",
15
- "react": "^18.2.0",
16
- "react-dom": "^18.2.0"
17
- },
18
- "devDependencies": {
19
- "@types/react": "^18.0.37",
20
- "@types/react-dom": "^18.0.11",
21
- "@typescript-eslint/eslint-plugin": "^5.59.0",
22
- "@typescript-eslint/parser": "^5.59.0",
23
- "@vitejs/plugin-react": "^4.0.0",
24
- "eslint": "^8.38.0",
25
- "eslint-plugin-react-hooks": "^4.6.0",
26
- "eslint-plugin-react-refresh": "^0.3.4",
27
- "typescript": "^5.0.2",
28
- "vite": "^4.3.9"
29
- }
30
- }
1
+ {
2
+ "name": "example",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc && vite build",
9
+ "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
10
+ "preview": "vite preview"
11
+ },
12
+ "dependencies": {
13
+ "@fortawesome/fontawesome-free": "^6.4.0",
14
+ "@seeqdev/qomponents": "0.0.72",
15
+ "react": "^18.2.0",
16
+ "react-dom": "^18.2.0"
17
+ },
18
+ "devDependencies": {
19
+ "@types/react": "^18.0.37",
20
+ "@types/react-dom": "^18.0.11",
21
+ "@typescript-eslint/eslint-plugin": "^5.59.0",
22
+ "@typescript-eslint/parser": "^5.59.0",
23
+ "@vitejs/plugin-react": "^4.0.0",
24
+ "eslint": "^8.38.0",
25
+ "eslint-plugin-react-hooks": "^4.6.0",
26
+ "eslint-plugin-react-refresh": "^0.3.4",
27
+ "typescript": "^5.0.2",
28
+ "vite": "^4.3.9"
29
+ }
30
+ }
@@ -1,81 +1,81 @@
1
- import React from 'react';
2
- import { Icon, Select } from '@seeqdev/qomponents';
3
-
4
- export interface SelectOption {
5
- id: string;
6
- label: string;
7
- color: string;
8
- asset: string;
9
- type: 'SCALAR' | 'STRING' | 'NUMERIC';
10
- }
11
-
12
- const options: SelectOption[] = [
13
- { id: '1', label: 'Label for the first entry', color: 'pink', asset: 'Asset 1', type: 'NUMERIC' },
14
- { id: '2', label: 'Label for the second entry', color: 'green', asset: 'Asset 2', type: 'SCALAR' },
15
- { id: '3', label: 'Label for the third entry', color: 'orange', asset: 'Asset 3', type: 'STRING' },
16
- ];
17
-
18
- interface ComplexSelectExampleProps {
19
- onChange: (selectedOption: SelectOption) => void;
20
- value: SelectOption | undefined;
21
- }
22
-
23
- function ComplexSelectExample({ onChange, value }: ComplexSelectExampleProps) {
24
- const getIcon = (type: string) => {
25
- switch (type) {
26
- case 'STRING':
27
- return 'fa fa-font';
28
- case 'SCALAR':
29
- return 'fc-scalar';
30
- default:
31
- return 'fc-series';
32
- }
33
- };
34
- /**
35
- * This function formats the select option as desired. You can apply css styling here or use additional qomponents
36
- * to style the select option display.
37
- *
38
- * You can use the same function to format the selected value or use a different one (sometimes having a separate
39
- * function is helpful if you want to limit the space that is taken up by the selected option).
40
- *
41
- * This example shows how to use an additional Icon component (styled in color based on the select option) as well
42
- * as how to display the properties of the select option
43
- */
44
- const getOptionLabel = (optionValue: SelectOption): React.ReactNode => {
45
- return (
46
- <div className="selectOptionWrapperDiv">
47
- <Icon icon={getIcon(optionValue.type)} type="color" color={optionValue.color} extraClassNames="mr-10" />
48
- <div className="selectOptionDiv">
49
- <div className="selectOption">
50
- <strong>{optionValue.label}</strong>
51
- </div>
52
- <div className="selectOptionSubText">{optionValue.asset}</div>
53
- </div>
54
- </div>
55
- );
56
- };
57
- const getOptionValue = (option: SelectOption) => {
58
- return option.id;
59
- };
60
-
61
- return (
62
- // use the getOptionLabel function to provide a custom render function that determines how the select options
63
- // are displayed
64
- // use the getSelectedValueLabel function to provide a custom render function that determines how the selected
65
- // option is displayed
66
- <Select
67
- placeholder="formatted select options"
68
- extraClassNames="formElementWidth"
69
- options={options}
70
- value={value}
71
- getOptionLabel={getOptionLabel}
72
- getOptionValue={getOptionValue}
73
- getSelectedValueLabel={getOptionLabel}
74
- onChange={(selectedOption: SelectOption) => {
75
- onChange(selectedOption);
76
- }}
77
- />
78
- );
79
- }
80
-
81
- export default ComplexSelectExample;
1
+ import React from 'react';
2
+ import { Icon, Select } from '@seeqdev/qomponents';
3
+
4
+ export interface SelectOption {
5
+ id: string;
6
+ label: string;
7
+ color: string;
8
+ asset: string;
9
+ type: 'SCALAR' | 'STRING' | 'NUMERIC';
10
+ }
11
+
12
+ const options: SelectOption[] = [
13
+ { id: '1', label: 'Label for the first entry', color: 'pink', asset: 'Asset 1', type: 'NUMERIC' },
14
+ { id: '2', label: 'Label for the second entry', color: 'green', asset: 'Asset 2', type: 'SCALAR' },
15
+ { id: '3', label: 'Label for the third entry', color: 'orange', asset: 'Asset 3', type: 'STRING' },
16
+ ];
17
+
18
+ interface ComplexSelectExampleProps {
19
+ onChange: (selectedOption: SelectOption) => void;
20
+ value: SelectOption | undefined;
21
+ }
22
+
23
+ function ComplexSelectExample({ onChange, value }: ComplexSelectExampleProps) {
24
+ const getIcon = (type: string) => {
25
+ switch (type) {
26
+ case 'STRING':
27
+ return 'fa fa-font';
28
+ case 'SCALAR':
29
+ return 'fc-scalar';
30
+ default:
31
+ return 'fc-series';
32
+ }
33
+ };
34
+ /**
35
+ * This function formats the select option as desired. You can apply css styling here or use additional qomponents
36
+ * to style the select option display.
37
+ *
38
+ * You can use the same function to format the selected value or use a different one (sometimes having a separate
39
+ * function is helpful if you want to limit the space that is taken up by the selected option).
40
+ *
41
+ * This example shows how to use an additional Icon component (styled in color based on the select option) as well
42
+ * as how to display the properties of the select option
43
+ */
44
+ const getOptionLabel = (optionValue: SelectOption): React.ReactNode => {
45
+ return (
46
+ <div className="selectOptionWrapperDiv">
47
+ <Icon icon={getIcon(optionValue.type)} type="color" color={optionValue.color} extraClassNames="mr-10" />
48
+ <div className="selectOptionDiv">
49
+ <div className="selectOption">
50
+ <strong>{optionValue.label}</strong>
51
+ </div>
52
+ <div className="selectOptionSubText">{optionValue.asset}</div>
53
+ </div>
54
+ </div>
55
+ );
56
+ };
57
+ const getOptionValue = (option: SelectOption) => {
58
+ return option.id;
59
+ };
60
+
61
+ return (
62
+ // use the getOptionLabel function to provide a custom render function that determines how the select options
63
+ // are displayed
64
+ // use the getSelectedValueLabel function to provide a custom render function that determines how the selected
65
+ // option is displayed
66
+ <Select
67
+ placeholder="formatted select options"
68
+ extraClassNames="formElementWidth"
69
+ options={options}
70
+ value={value}
71
+ getOptionLabel={getOptionLabel}
72
+ getOptionValue={getOptionValue}
73
+ getSelectedValueLabel={getOptionLabel}
74
+ onChange={(selectedOption: SelectOption) => {
75
+ onChange(selectedOption);
76
+ }}
77
+ />
78
+ );
79
+ }
80
+
81
+ export default ComplexSelectExample;