@bolttech/molecules-dropdown 0.1.5 → 0.1.7
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/{index.js → index.cjs} +57 -48
- package/package.json +4 -6
package/{index.js → index.cjs}
RENAMED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var atomsSelect = require('@bolttech/atoms-select');
|
|
8
|
+
var atomsIcon = require('@bolttech/atoms-icon');
|
|
9
|
+
var atomsInput = require('@bolttech/atoms-input');
|
|
10
|
+
var styled = require('styled-components');
|
|
11
|
+
|
|
12
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
|
+
|
|
14
|
+
var styled__default = /*#__PURE__*/_interopDefaultLegacy(styled);
|
|
7
15
|
|
|
8
16
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
9
17
|
|
|
@@ -1647,11 +1655,11 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
1647
1655
|
});
|
|
1648
1656
|
}
|
|
1649
1657
|
|
|
1650
|
-
const ClickableElement = /*#__PURE__*/
|
|
1658
|
+
const ClickableElement = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
1651
1659
|
displayName: "molecules-dropdownstyles__ClickableElement",
|
|
1652
1660
|
componentId: "sc-3wugi4-0"
|
|
1653
1661
|
})(["cursor:pointer;"]);
|
|
1654
|
-
const ContainerDropdown = /*#__PURE__*/
|
|
1662
|
+
const ContainerDropdown = /*#__PURE__*/styled__default["default"].section.withConfig({
|
|
1655
1663
|
displayName: "molecules-dropdownstyles__ContainerDropdown",
|
|
1656
1664
|
componentId: "sc-3wugi4-1"
|
|
1657
1665
|
})(["padding-top:", ";padding-bottom:", ";padding-right:", ";padding-left:", ";gap:", ";background-color:", ";border:", ";border-radius:", ";box-shadow:", ";.fieldLabel{color:", ";font-family:", ";font-weight:", ";line-height:", ";font-size:", ";letter-spacing:", ";}.requiredLabel{color:", ";font-family:", ";font-weight:", ";line-height:", ";font-size:", ";letter-spacing:", ";}svg{width:", ";fill:", ";}input{color:", ";font-family:", ";font-weight:", ";line-height:", ";font-size:", ";letter-spacing:", ";}&:focus-within{background-color:", ";border:", ";", "}", " ", ""], ({
|
|
@@ -1735,7 +1743,7 @@ const ContainerDropdown = /*#__PURE__*/styled.section.withConfig({
|
|
|
1735
1743
|
hasError
|
|
1736
1744
|
}) => `1px solid ${theme.components.dropdown[variant].container.border[hasError ? 'error' : 'focus']}`, ({
|
|
1737
1745
|
hasError
|
|
1738
|
-
}) => !hasError && css([".fieldLabel{color:", ";}.requiredLabel{color:", ";}svg{fill:", ";}"], ({
|
|
1746
|
+
}) => !hasError && styled.css([".fieldLabel{color:", ";}.requiredLabel{color:", ";}svg{fill:", ";}"], ({
|
|
1739
1747
|
theme,
|
|
1740
1748
|
variant
|
|
1741
1749
|
}) => theme.components.dropdown[variant].text.color.fieldLabel.focus, ({
|
|
@@ -1747,7 +1755,7 @@ const ContainerDropdown = /*#__PURE__*/styled.section.withConfig({
|
|
|
1747
1755
|
}) => theme.components.dropdown[variant].icon.color.focus), ({
|
|
1748
1756
|
hasError,
|
|
1749
1757
|
hasValue
|
|
1750
|
-
}) => hasError && css(["border:", ";background-color:", ";.fieldLabel{color:", ";}.requiredLabel{color:", ";}svg{fill:", ";}"], ({
|
|
1758
|
+
}) => hasError && styled.css(["border:", ";background-color:", ";.fieldLabel{color:", ";}.requiredLabel{color:", ";}svg{fill:", ";}"], ({
|
|
1751
1759
|
theme,
|
|
1752
1760
|
variant
|
|
1753
1761
|
}) => `1px solid ${theme.components.dropdown[variant].container.border[hasValue ? 'errorFilled' : 'error']}`, ({
|
|
@@ -1766,7 +1774,7 @@ const ContainerDropdown = /*#__PURE__*/styled.section.withConfig({
|
|
|
1766
1774
|
variant
|
|
1767
1775
|
}) => theme.components.dropdown[variant].icon.color[hasValue ? 'errorFilled' : 'error']), ({
|
|
1768
1776
|
disabled
|
|
1769
|
-
}) => disabled && css(["cursor:not-allowed;border:", ";background-color:", ";*{cursor:not-allowed;}.fieldLabel{color:", ";}.requiredLabel{color:", ";}svg{fill:", ";}input{::placeholder{color:", ";}}"], ({
|
|
1777
|
+
}) => disabled && styled.css(["cursor:not-allowed;border:", ";background-color:", ";*{cursor:not-allowed;}.fieldLabel{color:", ";}.requiredLabel{color:", ";}svg{fill:", ";}input{::placeholder{color:", ";}}"], ({
|
|
1770
1778
|
theme,
|
|
1771
1779
|
variant
|
|
1772
1780
|
}) => `1px solid ${theme.components.dropdown[variant].container.border.disable}`, ({
|
|
@@ -1785,7 +1793,7 @@ const ContainerDropdown = /*#__PURE__*/styled.section.withConfig({
|
|
|
1785
1793
|
theme,
|
|
1786
1794
|
variant
|
|
1787
1795
|
}) => theme.components.dropdown[variant].text.color.required.disable));
|
|
1788
|
-
const SectionContainer = /*#__PURE__*/
|
|
1796
|
+
const SectionContainer = /*#__PURE__*/styled__default["default"].section.withConfig({
|
|
1789
1797
|
displayName: "molecules-dropdownstyles__SectionContainer",
|
|
1790
1798
|
componentId: "sc-3wugi4-2"
|
|
1791
1799
|
})([".errorMessage{width:100%;padding-right:", ";padding-left:", ";label{color:", ";font-family:", ";font-weight:", ";line-height:", ";font-size:", ";letter-spacing:", ";}}"], ({
|
|
@@ -1806,17 +1814,17 @@ const SectionContainer = /*#__PURE__*/styled.section.withConfig({
|
|
|
1806
1814
|
}) => theme.components.dropdown.error.fontSize, ({
|
|
1807
1815
|
theme
|
|
1808
1816
|
}) => theme.components.dropdown.error.letterSpacing);
|
|
1809
|
-
const InputAndIconDropdown = /*#__PURE__*/
|
|
1817
|
+
const InputAndIconDropdown = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
1810
1818
|
displayName: "molecules-dropdownstyles__InputAndIconDropdown",
|
|
1811
1819
|
componentId: "sc-3wugi4-3"
|
|
1812
1820
|
})(["display:flex;"]);
|
|
1813
|
-
const ContentDropdown = /*#__PURE__*/
|
|
1821
|
+
const ContentDropdown = /*#__PURE__*/styled__default["default"].div.withConfig({
|
|
1814
1822
|
displayName: "molecules-dropdownstyles__ContentDropdown",
|
|
1815
1823
|
componentId: "sc-3wugi4-4"
|
|
1816
1824
|
})(["gap:", ";"], ({
|
|
1817
1825
|
theme
|
|
1818
1826
|
}) => theme.components.dropdown.gap);
|
|
1819
|
-
const FieldLabelAndRequiredLabelDropdown = /*#__PURE__*/
|
|
1827
|
+
const FieldLabelAndRequiredLabelDropdown = /*#__PURE__*/styled__default["default"](ClickableElement).withConfig({
|
|
1820
1828
|
displayName: "molecules-dropdownstyles__FieldLabelAndRequiredLabelDropdown",
|
|
1821
1829
|
componentId: "sc-3wugi4-5"
|
|
1822
1830
|
})(["gap:", ";display:flex;"], ({
|
|
@@ -1839,33 +1847,33 @@ const ReusableDropdownComponent = ({
|
|
|
1839
1847
|
dataTestId,
|
|
1840
1848
|
placeholder
|
|
1841
1849
|
}) => {
|
|
1842
|
-
return jsxs(Fragment, {
|
|
1843
|
-
children: [jsx(ContainerDropdown, Object.assign({
|
|
1850
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1851
|
+
children: [jsxRuntime.jsx(ContainerDropdown, Object.assign({
|
|
1844
1852
|
variant: _variant,
|
|
1845
1853
|
hasValue: inputValue,
|
|
1846
1854
|
hasError: hasError,
|
|
1847
1855
|
disabled: disabled,
|
|
1848
1856
|
"data-testid": `${dataTestId}-dropdown-container`
|
|
1849
1857
|
}, {
|
|
1850
|
-
children: jsxs(ContentDropdown, {
|
|
1851
|
-
children: [jsxs(FieldLabelAndRequiredLabelDropdown, Object.assign({
|
|
1858
|
+
children: jsxRuntime.jsxs(ContentDropdown, {
|
|
1859
|
+
children: [jsxRuntime.jsxs(FieldLabelAndRequiredLabelDropdown, Object.assign({
|
|
1852
1860
|
onClick: () => {
|
|
1853
1861
|
setShowSelectComponent(disabled ? false : !showSelectComponent);
|
|
1854
1862
|
}
|
|
1855
1863
|
}, {
|
|
1856
|
-
children: [jsx("label", Object.assign({
|
|
1864
|
+
children: [jsxRuntime.jsx("label", Object.assign({
|
|
1857
1865
|
className: "fieldLabel",
|
|
1858
1866
|
"data-testid": `${dataTestId}-label`
|
|
1859
1867
|
}, {
|
|
1860
1868
|
children: label
|
|
1861
|
-
})), required && jsx("label", Object.assign({
|
|
1869
|
+
})), required && jsxRuntime.jsx("label", Object.assign({
|
|
1862
1870
|
className: "requiredLabel",
|
|
1863
1871
|
"data-testid": `${dataTestId}-label-required`
|
|
1864
1872
|
}, {
|
|
1865
1873
|
children: "*"
|
|
1866
1874
|
}))]
|
|
1867
|
-
})), jsxs(InputAndIconDropdown, {
|
|
1868
|
-
children: [jsx(InputStyled, {
|
|
1875
|
+
})), jsxRuntime.jsxs(InputAndIconDropdown, {
|
|
1876
|
+
children: [jsxRuntime.jsx(atomsInput.InputStyled, {
|
|
1869
1877
|
"data-testid": `${dataTestId}-input`,
|
|
1870
1878
|
ref: inputRef,
|
|
1871
1879
|
disabled: disabled,
|
|
@@ -1885,22 +1893,22 @@ const ReusableDropdownComponent = ({
|
|
|
1885
1893
|
setSelectedOptionOnInputValue();
|
|
1886
1894
|
setShowSelectComponent(false);
|
|
1887
1895
|
}
|
|
1888
|
-
}), jsx(ClickableElement, Object.assign({
|
|
1896
|
+
}), jsxRuntime.jsx(ClickableElement, Object.assign({
|
|
1889
1897
|
onClick: () => {
|
|
1890
1898
|
if (!disabled) setShowSelectComponent(!showSelectComponent);
|
|
1891
1899
|
}
|
|
1892
1900
|
}, {
|
|
1893
|
-
children: jsx(Icon, {
|
|
1901
|
+
children: jsxRuntime.jsx(atomsIcon.Icon, {
|
|
1894
1902
|
dataTestId: `${dataTestId}-icon`,
|
|
1895
1903
|
icon: !showSelectComponent ? 'keyboard_arrow_down' : 'keyboard_arrow_up'
|
|
1896
1904
|
})
|
|
1897
1905
|
}))]
|
|
1898
1906
|
})]
|
|
1899
1907
|
})
|
|
1900
|
-
})), !showSelectComponent && hasError && errorMessage && jsx("div", Object.assign({
|
|
1908
|
+
})), !showSelectComponent && hasError && errorMessage && jsxRuntime.jsx("div", Object.assign({
|
|
1901
1909
|
className: "errorMessage"
|
|
1902
1910
|
}, {
|
|
1903
|
-
children: jsx("label", Object.assign({
|
|
1911
|
+
children: jsxRuntime.jsx("label", Object.assign({
|
|
1904
1912
|
"data-testid": `${dataTestId}-label-error-message`
|
|
1905
1913
|
}, {
|
|
1906
1914
|
children: errorMessage
|
|
@@ -2399,17 +2407,17 @@ const Dropdown = ({
|
|
|
2399
2407
|
setSelectedOption,
|
|
2400
2408
|
placeholder
|
|
2401
2409
|
}) => {
|
|
2402
|
-
const [showSelectComponent, setShowSelectComponent] = useState(false);
|
|
2403
|
-
const [currentOptionList, setCurrentOptionList] = useState([]);
|
|
2404
|
-
const [inputValue, setInputValue] = useState('');
|
|
2405
|
-
const inputRef = useRef(null);
|
|
2406
|
-
useEffect(() => {
|
|
2410
|
+
const [showSelectComponent, setShowSelectComponent] = react.useState(false);
|
|
2411
|
+
const [currentOptionList, setCurrentOptionList] = react.useState([]);
|
|
2412
|
+
const [inputValue, setInputValue] = react.useState('');
|
|
2413
|
+
const inputRef = react.useRef(null);
|
|
2414
|
+
react.useEffect(() => {
|
|
2407
2415
|
const normalizeOptionList = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2408
2416
|
return yield _filterOptionsParam(inputValue, optionList, urlFilterOptions);
|
|
2409
2417
|
});
|
|
2410
2418
|
normalizeOptionList().then(optionsResponse => setCurrentOptionList([...optionsResponse])).catch(error => console.error('An error happens when trying to normalize options', error));
|
|
2411
2419
|
}, [_filterOptionsParam, optionList, urlFilterOptions, inputValue]);
|
|
2412
|
-
const setSelectedOptionOnInputValue = useCallback(() => {
|
|
2420
|
+
const setSelectedOptionOnInputValue = react.useCallback(() => {
|
|
2413
2421
|
if (!inputValue && selectedOption) {
|
|
2414
2422
|
setInputValue((selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) || '');
|
|
2415
2423
|
return;
|
|
@@ -2419,7 +2427,7 @@ const Dropdown = ({
|
|
|
2419
2427
|
if (!isValidValue) setInputValue((selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) || '');
|
|
2420
2428
|
}
|
|
2421
2429
|
}, [currentOptionList, inputValue, selectedOption]);
|
|
2422
|
-
return jsxs(SectionContainer, Object.assign({
|
|
2430
|
+
return jsxRuntime.jsxs(SectionContainer, Object.assign({
|
|
2423
2431
|
onClick: () => {
|
|
2424
2432
|
var _a;
|
|
2425
2433
|
return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
@@ -2427,7 +2435,7 @@ const Dropdown = ({
|
|
|
2427
2435
|
variant: _variant,
|
|
2428
2436
|
"data-testid": `${dataTestId}-container`
|
|
2429
2437
|
}, {
|
|
2430
|
-
children: [jsx(ReusableDropdownComponent, {
|
|
2438
|
+
children: [jsxRuntime.jsx(ReusableDropdownComponent, {
|
|
2431
2439
|
label: label,
|
|
2432
2440
|
variant: _variant,
|
|
2433
2441
|
required: required,
|
|
@@ -2442,8 +2450,8 @@ const Dropdown = ({
|
|
|
2442
2450
|
setShowSelectComponent: setShowSelectComponent,
|
|
2443
2451
|
onChangeInputValue: setInputValue,
|
|
2444
2452
|
setSelectedOptionOnInputValue: setSelectedOptionOnInputValue
|
|
2445
|
-
}), showSelectComponent && !disabled && jsx("div", {
|
|
2446
|
-
children: jsx(Select, {
|
|
2453
|
+
}), showSelectComponent && !disabled && jsxRuntime.jsx("div", {
|
|
2454
|
+
children: jsxRuntime.jsx(atomsSelect.Select, {
|
|
2447
2455
|
dataTestId: `${dataTestId}-select`,
|
|
2448
2456
|
onChange: selectedValue => {
|
|
2449
2457
|
setInputValue(selectedValue.value);
|
|
@@ -2471,17 +2479,17 @@ const DropdownOptionsWithHeaders = ({
|
|
|
2471
2479
|
setSelectedOption,
|
|
2472
2480
|
placeholder
|
|
2473
2481
|
}) => {
|
|
2474
|
-
const [showSelectComponent, setShowSelectComponent] = useState(false);
|
|
2475
|
-
const [currentOptionList, setCurrentOptionList] = useState([]);
|
|
2476
|
-
const [inputValue, setInputValue] = useState('');
|
|
2477
|
-
const inputRef = useRef(null);
|
|
2478
|
-
useEffect(() => {
|
|
2482
|
+
const [showSelectComponent, setShowSelectComponent] = react.useState(false);
|
|
2483
|
+
const [currentOptionList, setCurrentOptionList] = react.useState([]);
|
|
2484
|
+
const [inputValue, setInputValue] = react.useState('');
|
|
2485
|
+
const inputRef = react.useRef(null);
|
|
2486
|
+
react.useEffect(() => {
|
|
2479
2487
|
const normalizeOptionList = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2480
2488
|
return yield _filterOptionsParam(inputValue, optionList, urlFilterOptions);
|
|
2481
2489
|
});
|
|
2482
2490
|
normalizeOptionList().then(optionsResponse => setCurrentOptionList([...optionsResponse])).catch(error => console.error('An error happens when trying to normalize options', error));
|
|
2483
2491
|
}, [_filterOptionsParam, optionList, urlFilterOptions, inputValue]);
|
|
2484
|
-
const setSelectedOptionOnInputValue = useCallback(() => {
|
|
2492
|
+
const setSelectedOptionOnInputValue = react.useCallback(() => {
|
|
2485
2493
|
if (!inputValue && selectedOption) {
|
|
2486
2494
|
setInputValue((selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) || '');
|
|
2487
2495
|
return;
|
|
@@ -2495,7 +2503,7 @@ const DropdownOptionsWithHeaders = ({
|
|
|
2495
2503
|
if (!isValidValue) setInputValue((selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) || '');
|
|
2496
2504
|
}
|
|
2497
2505
|
}, [currentOptionList, inputValue, selectedOption]);
|
|
2498
|
-
return jsxs(SectionContainer, Object.assign({
|
|
2506
|
+
return jsxRuntime.jsxs(SectionContainer, Object.assign({
|
|
2499
2507
|
onClick: () => {
|
|
2500
2508
|
var _a;
|
|
2501
2509
|
return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
@@ -2503,7 +2511,7 @@ const DropdownOptionsWithHeaders = ({
|
|
|
2503
2511
|
variant: _variant,
|
|
2504
2512
|
"data-testid": `${dataTestId}-container`
|
|
2505
2513
|
}, {
|
|
2506
|
-
children: [jsx(ReusableDropdownComponent, {
|
|
2514
|
+
children: [jsxRuntime.jsx(ReusableDropdownComponent, {
|
|
2507
2515
|
label: label,
|
|
2508
2516
|
variant: _variant,
|
|
2509
2517
|
required: required,
|
|
@@ -2518,8 +2526,8 @@ const DropdownOptionsWithHeaders = ({
|
|
|
2518
2526
|
setShowSelectComponent: setShowSelectComponent,
|
|
2519
2527
|
onChangeInputValue: setInputValue,
|
|
2520
2528
|
setSelectedOptionOnInputValue: setSelectedOptionOnInputValue
|
|
2521
|
-
}), showSelectComponent && !disabled && jsx("div", {
|
|
2522
|
-
children: jsx(SelectWithHeaders, {
|
|
2529
|
+
}), showSelectComponent && !disabled && jsxRuntime.jsx("div", {
|
|
2530
|
+
children: jsxRuntime.jsx(atomsSelect.SelectWithHeaders, {
|
|
2523
2531
|
dataTestId: `${dataTestId}-select`,
|
|
2524
2532
|
onChange: selectedValue => {
|
|
2525
2533
|
setInputValue(selectedValue.value);
|
|
@@ -2532,4 +2540,5 @@ const DropdownOptionsWithHeaders = ({
|
|
|
2532
2540
|
}));
|
|
2533
2541
|
};
|
|
2534
2542
|
|
|
2535
|
-
|
|
2543
|
+
exports.Dropdown = Dropdown;
|
|
2544
|
+
exports.DropdownOptionsWithHeaders = DropdownOptionsWithHeaders;
|
package/package.json
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bolttech/molecules-dropdown",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@bolttech/atoms-icon": "0.0.1",
|
|
6
6
|
"@bolttech/atoms-input": "0.0.1"
|
|
7
7
|
},
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"type": "module",
|
|
8
|
+
"main": "./index.cjs",
|
|
9
|
+
"type": "commonjs",
|
|
11
10
|
"types": "./src/index.d.ts",
|
|
12
11
|
"peerDependencies": {
|
|
13
|
-
"@bolttech/atoms-select": "0.1.
|
|
14
|
-
"@edirect/frontend-foundations": "0.0.27",
|
|
12
|
+
"@bolttech/atoms-select": "0.1.6",
|
|
15
13
|
"jest-styled-components": "7.1.1",
|
|
16
14
|
"react": "18.2.0",
|
|
17
15
|
"styled-components": "5.3.6"
|