venice-ui 1.0.40 → 1.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Theme/Theme.js +4 -1
- package/dist/cjs/components/Selector/Selector.js +14 -11
- package/dist/cjs/components/Selector/Selector.styles.js +2 -4
- package/dist/esm/Theme/Theme.js +4 -1
- package/dist/esm/components/Selector/Selector.js +14 -11
- package/dist/esm/components/Selector/Selector.styles.js +2 -4
- package/dist/types/Theme/Theme.d.ts +2 -0
- package/dist/types/components/Selector/Selector.d.ts +3 -0
- package/dist/types/components/Selector/Selector.styles.d.ts +1 -0
- package/package.json +1 -1
package/dist/cjs/Theme/Theme.js
CHANGED
|
@@ -76,5 +76,8 @@ exports.mainTheme = {
|
|
|
76
76
|
inputErrorBorder: exports.Theme.colors.red,
|
|
77
77
|
inputErrorTextColor: exports.Theme.colors.red,
|
|
78
78
|
// global
|
|
79
|
-
contentBackground: exports.Theme.colors.white
|
|
79
|
+
contentBackground: exports.Theme.colors.white,
|
|
80
|
+
// selector / dropdown
|
|
81
|
+
optionActiveColor: exports.Theme.colors.primary,
|
|
82
|
+
optionHoverBackground: (0, polished_1.lighten)(0.3, exports.Theme.colors.primary)
|
|
80
83
|
};
|
|
@@ -24,14 +24,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.Selector = void 0;
|
|
27
|
-
const Aligment_1 = require("../Aligment");
|
|
28
27
|
const react_1 = __importStar(require("react"));
|
|
28
|
+
const Aligment_1 = require("../Aligment");
|
|
29
|
+
const Theme_1 = require("../../Theme/Theme");
|
|
29
30
|
const Input_1 = require("../Input");
|
|
30
31
|
const Icons_1 = require("../Icons");
|
|
31
32
|
const Selector_styles_1 = require("./Selector.styles");
|
|
32
33
|
const Modal_1 = require("../Modal");
|
|
33
34
|
const common_1 = require("../common");
|
|
34
|
-
const
|
|
35
|
+
const styled_components_1 = require("styled-components");
|
|
36
|
+
const Typography_1 = require("../Typography");
|
|
37
|
+
const Selector = ({ theme = Theme_1.mainTheme, label, labelPosition = 'top', size = 'medium', width, options, value, name, error, handleSelect, handleClear, iconName = 'add_circle', optionsPanelTitle = 'Please select', optionsPanelEmptyMsg = 'There are no options to choose from', }) => {
|
|
35
38
|
const [open, toogleOpen] = (0, react_1.useState)(false);
|
|
36
39
|
const selectOption = (selectedValue) => {
|
|
37
40
|
handleSelect(name, selectedValue);
|
|
@@ -40,14 +43,14 @@ const Selector = ({ label, labelPosition = 'top', size = 'medium', width, option
|
|
|
40
43
|
const getLabelForValue = (value) => {
|
|
41
44
|
return options.find((option) => option.value === value).label;
|
|
42
45
|
};
|
|
43
|
-
return (react_1.default.createElement(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
react_1.default.createElement(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
options.map((option) => (react_1.default.createElement(common_1.PanelOption, { key: option.value, active: option.value === value, onClick: () => selectOption(option.value) }, option.label))))),
|
|
51
|
-
|
|
46
|
+
return (react_1.default.createElement(styled_components_1.ThemeProvider, { theme: theme },
|
|
47
|
+
react_1.default.createElement(Aligment_1.Aligment, { align: labelPosition === 'top' ? 'flex-start' : 'center', justify: labelPosition === 'top' ? 'center' : 'flex-start', direction: labelPosition === 'top' ? 'column' : 'row', wrap: 'nowrap', width: width },
|
|
48
|
+
label && (react_1.default.createElement(Input_1.InputLabelElement, { size: size, labelPosition: labelPosition }, label)),
|
|
49
|
+
react_1.default.createElement(Selector_styles_1.SelectorElement, null,
|
|
50
|
+
value ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
51
|
+
react_1.default.createElement(Selector_styles_1.SelectorValue, { onClick: () => toogleOpen(true), size: size }, getLabelForValue(value)),
|
|
52
|
+
react_1.default.createElement(Icons_1.Icon, { name: 'close', onClick: () => handleClear(), size: (0, common_1.setIconSize)(size) }))) : (react_1.default.createElement(Icons_1.Icon, { name: iconName, onClick: () => toogleOpen(true), size: (0, common_1.setIconSize)(size) })),
|
|
53
|
+
open && (react_1.default.createElement(Modal_1.Modal, { title: optionsPanelTitle, labelClose: "Close", handleClose: () => toogleOpen(false) }, options?.length > 0 ? (options.map((option) => (react_1.default.createElement(common_1.PanelOption, { key: option.value, active: option.value === value, onClick: () => selectOption(option.value) }, option.label)))) : (react_1.default.createElement(Typography_1.Text, null, optionsPanelEmptyMsg)))),
|
|
54
|
+
error && react_1.default.createElement(Input_1.InputErrorMsg, null, error)))));
|
|
52
55
|
};
|
|
53
56
|
exports.Selector = Selector;
|
|
@@ -5,8 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.SelectorValue = exports.SelectorElement = void 0;
|
|
7
7
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
|
-
const Theme_1 = require("../../Theme");
|
|
9
|
-
const polished_1 = require("polished");
|
|
10
8
|
const common_1 = require("../common");
|
|
11
9
|
exports.SelectorElement = styled_components_1.default.div `
|
|
12
10
|
position: relative;
|
|
@@ -21,9 +19,9 @@ exports.SelectorValue = styled_components_1.default.div `
|
|
|
21
19
|
display:flex;
|
|
22
20
|
align-items: center;
|
|
23
21
|
${(p) => (0, common_1.setSize)(p.size)}
|
|
24
|
-
color:${
|
|
22
|
+
color:${p => p.theme.optionActiveColor};
|
|
25
23
|
&:hover{
|
|
26
|
-
background-color: ${
|
|
24
|
+
background-color: ${p => p.theme.optionHoverBackground};
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
`;
|
package/dist/esm/Theme/Theme.js
CHANGED
|
@@ -73,5 +73,8 @@ export const mainTheme = {
|
|
|
73
73
|
inputErrorBorder: Theme.colors.red,
|
|
74
74
|
inputErrorTextColor: Theme.colors.red,
|
|
75
75
|
// global
|
|
76
|
-
contentBackground: Theme.colors.white
|
|
76
|
+
contentBackground: Theme.colors.white,
|
|
77
|
+
// selector / dropdown
|
|
78
|
+
optionActiveColor: Theme.colors.primary,
|
|
79
|
+
optionHoverBackground: lighten(0.3, Theme.colors.primary)
|
|
77
80
|
};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { Aligment } from '../Aligment';
|
|
2
1
|
import React, { useState } from 'react';
|
|
2
|
+
import { Aligment } from '../Aligment';
|
|
3
|
+
import { mainTheme } from '../../Theme/Theme';
|
|
3
4
|
import { InputErrorMsg, InputLabelElement } from '../Input';
|
|
4
5
|
import { Icon } from '../Icons';
|
|
5
6
|
import { SelectorElement, SelectorValue } from './Selector.styles';
|
|
6
7
|
import { Modal } from '../Modal';
|
|
7
8
|
import { PanelOption, setIconSize } from '../common';
|
|
8
|
-
|
|
9
|
+
import { ThemeProvider } from 'styled-components';
|
|
10
|
+
import { Text } from '../Typography';
|
|
11
|
+
export const Selector = ({ theme = mainTheme, label, labelPosition = 'top', size = 'medium', width, options, value, name, error, handleSelect, handleClear, iconName = 'add_circle', optionsPanelTitle = 'Please select', optionsPanelEmptyMsg = 'There are no options to choose from', }) => {
|
|
9
12
|
const [open, toogleOpen] = useState(false);
|
|
10
13
|
const selectOption = (selectedValue) => {
|
|
11
14
|
handleSelect(name, selectedValue);
|
|
@@ -14,13 +17,13 @@ export const Selector = ({ label, labelPosition = 'top', size = 'medium', width,
|
|
|
14
17
|
const getLabelForValue = (value) => {
|
|
15
18
|
return options.find((option) => option.value === value).label;
|
|
16
19
|
};
|
|
17
|
-
return (React.createElement(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
React.createElement(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
options.map((option) => (React.createElement(PanelOption, { key: option.value, active: option.value === value, onClick: () => selectOption(option.value) }, option.label))))),
|
|
25
|
-
|
|
20
|
+
return (React.createElement(ThemeProvider, { theme: theme },
|
|
21
|
+
React.createElement(Aligment, { align: labelPosition === 'top' ? 'flex-start' : 'center', justify: labelPosition === 'top' ? 'center' : 'flex-start', direction: labelPosition === 'top' ? 'column' : 'row', wrap: 'nowrap', width: width },
|
|
22
|
+
label && (React.createElement(InputLabelElement, { size: size, labelPosition: labelPosition }, label)),
|
|
23
|
+
React.createElement(SelectorElement, null,
|
|
24
|
+
value ? (React.createElement(React.Fragment, null,
|
|
25
|
+
React.createElement(SelectorValue, { onClick: () => toogleOpen(true), size: size }, getLabelForValue(value)),
|
|
26
|
+
React.createElement(Icon, { name: 'close', onClick: () => handleClear(), size: setIconSize(size) }))) : (React.createElement(Icon, { name: iconName, onClick: () => toogleOpen(true), size: setIconSize(size) })),
|
|
27
|
+
open && (React.createElement(Modal, { title: optionsPanelTitle, labelClose: "Close", handleClose: () => toogleOpen(false) }, options?.length > 0 ? (options.map((option) => (React.createElement(PanelOption, { key: option.value, active: option.value === value, onClick: () => selectOption(option.value) }, option.label)))) : (React.createElement(Text, null, optionsPanelEmptyMsg)))),
|
|
28
|
+
error && React.createElement(InputErrorMsg, null, error)))));
|
|
26
29
|
};
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
|
-
import { Theme } from "../../Theme";
|
|
3
|
-
import { lighten } from "polished";
|
|
4
2
|
import { defaultStyles, setSize } from "../common";
|
|
5
3
|
export const SelectorElement = styled.div `
|
|
6
4
|
position: relative;
|
|
@@ -15,9 +13,9 @@ export const SelectorValue = styled.div `
|
|
|
15
13
|
display:flex;
|
|
16
14
|
align-items: center;
|
|
17
15
|
${(p) => setSize(p.size)}
|
|
18
|
-
color:${
|
|
16
|
+
color:${p => p.theme.optionActiveColor};
|
|
19
17
|
&:hover{
|
|
20
|
-
background-color: ${
|
|
18
|
+
background-color: ${p => p.theme.optionHoverBackground};
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
`;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { InputSize, IOption, LabelPosition } from '../../types';
|
|
3
3
|
export interface ISelectorProps {
|
|
4
|
+
theme?: any;
|
|
4
5
|
label?: string;
|
|
5
6
|
labelPosition?: LabelPosition;
|
|
6
7
|
size?: InputSize;
|
|
@@ -12,5 +13,7 @@ export interface ISelectorProps {
|
|
|
12
13
|
handleSelect: (name: string, value: string | number) => void;
|
|
13
14
|
handleClear: () => void;
|
|
14
15
|
iconName?: string;
|
|
16
|
+
optionsPanelTitle?: string;
|
|
17
|
+
optionsPanelEmptyMsg?: string;
|
|
15
18
|
}
|
|
16
19
|
export declare const Selector: FC<ISelectorProps>;
|
|
@@ -2,6 +2,7 @@ import { InputSize } from "../../types";
|
|
|
2
2
|
export declare const SelectorElement: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
3
|
interface ISelectorValueStyle {
|
|
4
4
|
size: InputSize;
|
|
5
|
+
theme: any;
|
|
5
6
|
}
|
|
6
7
|
export declare const SelectorValue: import("styled-components").StyledComponent<"div", any, ISelectorValueStyle, never>;
|
|
7
8
|
export {};
|