@bikdotai/bik-component-library 0.0.875-beta.3 → 0.0.875
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/components/dropdown/OpenedDropdown/components/OpennedDropdown.js +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/OpennedDropdown.js.map +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/MenuItem.js +10 -27
- package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/MenuItem.js.map +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/MenuList.js +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/MenuList.js.map +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/SelectAllMenu.js +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/menu/SelectAllMenu.js.map +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.js +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.js.map +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/utils/iterationOnOptions.js +1 -1
- package/dist/cjs/components/dropdown/OpenedDropdown/utils/iterationOnOptions.js.map +1 -1
- package/dist/cjs/components/dropdown/hooks/useDropdown.js +1 -1
- package/dist/cjs/components/dropdown/hooks/useDropdown.js.map +1 -1
- package/dist/cjs/components/toaster/Toaster.styled.js +20 -35
- package/dist/cjs/components/toaster/Toaster.styled.js.map +1 -1
- package/dist/esm/components/dropdown/OpenedDropdown/components/OpennedDropdown.js +278 -300
- package/dist/esm/components/dropdown/OpenedDropdown/components/OpennedDropdown.js.map +1 -1
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuItem.d.ts +0 -8
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuItem.js +126 -170
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuItem.js.map +1 -1
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuList.d.ts +0 -4
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuList.js +112 -144
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/MenuList.js.map +1 -1
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/SelectAllMenu.d.ts +0 -1
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/SelectAllMenu.js +31 -32
- package/dist/esm/components/dropdown/OpenedDropdown/components/menu/SelectAllMenu.js.map +1 -1
- package/dist/esm/components/dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.d.ts +0 -2
- package/dist/esm/components/dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.js +39 -54
- package/dist/esm/components/dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.js.map +1 -1
- package/dist/esm/components/dropdown/OpenedDropdown/utils/iterationOnOptions.d.ts +16 -18
- package/dist/esm/components/dropdown/OpenedDropdown/utils/iterationOnOptions.js +27 -73
- package/dist/esm/components/dropdown/OpenedDropdown/utils/iterationOnOptions.js.map +1 -1
- package/dist/esm/components/dropdown/hooks/useDropdown.d.ts +17 -4
- package/dist/esm/components/dropdown/hooks/useDropdown.js +163 -176
- package/dist/esm/components/dropdown/hooks/useDropdown.js.map +1 -1
- package/dist/esm/components/dropdown/type.d.ts +0 -22
- package/dist/esm/components/toaster/Toaster.styled.js +22 -37
- package/dist/esm/components/toaster/Toaster.styled.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,62 +1,47 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as n, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import { BodySecondary as C } from "../../../../TypographyStyle.js";
|
|
3
|
-
import { COLORS as
|
|
4
|
-
import { getSelectionLeaves as b } from "../../utils/iterationOnOptions.js";
|
|
3
|
+
import { COLORS as b } from "../../../../../constants/Theme.js";
|
|
5
4
|
import { BottomBarContainer as h } from "./MultiSelectDropdownBottomBar.styled.js";
|
|
6
|
-
import { Button as
|
|
7
|
-
const k = (
|
|
8
|
-
const {
|
|
9
|
-
|
|
10
|
-
onApply: i,
|
|
11
|
-
list: s,
|
|
12
|
-
buttonText: p,
|
|
13
|
-
buttonOptions: a,
|
|
14
|
-
hideClearButton: c,
|
|
15
|
-
hideSelectedCount: m,
|
|
16
|
-
childrenLayout: y
|
|
17
|
-
} = r, {
|
|
18
|
-
primaryButtonText: u,
|
|
5
|
+
import { Button as l } from "../../../../button/Button.js";
|
|
6
|
+
const k = (i) => {
|
|
7
|
+
const { onClear: s, onApply: p, list: c, buttonText: u, buttonOptions: a, hideClearButton: y } = i, {
|
|
8
|
+
primaryButtonText: m,
|
|
19
9
|
primaryButtonType: d,
|
|
20
10
|
secondaryButtonText: f,
|
|
21
11
|
secondaryButtonType: x
|
|
22
|
-
} = a ?? {},
|
|
23
|
-
(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
)
|
|
57
|
-
]
|
|
58
|
-
}
|
|
59
|
-
)
|
|
12
|
+
} = a ?? {}, r = c.reduce((t, e) => {
|
|
13
|
+
if (e.options) {
|
|
14
|
+
const B = e.options.filter(
|
|
15
|
+
(T) => T.selected === !0
|
|
16
|
+
).length;
|
|
17
|
+
return t + B;
|
|
18
|
+
}
|
|
19
|
+
return e.selected ? t + 1 : t;
|
|
20
|
+
}, 0);
|
|
21
|
+
return /* @__PURE__ */ n(h, { style: { justifyContent: "space-between" }, children: [
|
|
22
|
+
/* @__PURE__ */ o(C, { style: { flex: 1, color: b.content.primary }, children: r ? `${r} selected` : "" }),
|
|
23
|
+
/* @__PURE__ */ n("div", { style: { flexDirection: "row", display: "flex", gap: 12 }, children: [
|
|
24
|
+
!y && /* @__PURE__ */ o(
|
|
25
|
+
l,
|
|
26
|
+
{
|
|
27
|
+
size: "small",
|
|
28
|
+
buttonType: x || "primary",
|
|
29
|
+
buttonText: f || "Clear",
|
|
30
|
+
onClick: s
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
/* @__PURE__ */ o(
|
|
34
|
+
l,
|
|
35
|
+
{
|
|
36
|
+
size: "small",
|
|
37
|
+
buttonText: m || u || "Apply",
|
|
38
|
+
buttonType: d || "primary",
|
|
39
|
+
onClick: () => {
|
|
40
|
+
p();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
] })
|
|
60
45
|
] });
|
|
61
46
|
};
|
|
62
47
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelectDropdownBottomBar.js","sources":["../../../../../../../src/components/dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.tsx"],"sourcesContent":["import React from 'react';\nimport { Button } from '@src/components/button';\nimport { BodySecondary } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {
|
|
1
|
+
{"version":3,"file":"MultiSelectDropdownBottomBar.js","sources":["../../../../../../../src/components/dropdown/OpenedDropdown/components/multiSelect/MultiSelectDropdownBottomBar.tsx"],"sourcesContent":["import React from 'react';\nimport { Button } from '@src/components/button';\nimport { BodySecondary } from '@src/components/TypographyStyle';\nimport { COLORS } from '@src/constants/Theme';\nimport {\n\tButtonOptions,\n\tDropdownOption,\n\tGroupedOption,\n\tSingleOption,\n} from '../../../type';\nimport { BottomBarContainer } from './MultiSelectDropdownBottomBar.styled';\n\ninterface MultiSelectDropdownBottomBarProps {\n\tonClear?: () => void;\n\tonApply: () => void;\n\tlist: DropdownOption[];\n\tbuttonText?: string;\n\tbuttonOptions?: ButtonOptions;\n\thideClearButton?: boolean;\n}\nconst MultiSelectDropdownBottomBar: React.FC<\n\tMultiSelectDropdownBottomBarProps\n> = (props) => {\n\tconst { onClear, onApply, list, buttonText, buttonOptions, hideClearButton } =\n\t\tprops;\n\tconst {\n\t\tprimaryButtonText,\n\t\tprimaryButtonType,\n\t\tsecondaryButtonText,\n\t\tsecondaryButtonType,\n\t} = buttonOptions ?? {};\n\tconst count = list.reduce((total, option) => {\n\t\tif ((option as GroupedOption).options) {\n\t\t\tconst groupedTotal = (option as GroupedOption).options.filter(\n\t\t\t\t(op) => op.selected === true,\n\t\t\t).length;\n\t\t\treturn total + groupedTotal;\n\t\t}\n\n\t\treturn (option as SingleOption).selected ? total + 1 : total;\n\t}, 0);\n\n\treturn (\n\t\t<BottomBarContainer style={{ justifyContent: 'space-between' }}>\n\t\t\t<BodySecondary style={{ flex: 1, color: COLORS.content.primary }}>\n\t\t\t\t{count ? `${count} selected` : ''}\n\t\t\t</BodySecondary>\n\n\t\t\t<div style={{ flexDirection: 'row', display: 'flex', gap: 12 }}>\n\t\t\t\t{!hideClearButton && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\tbuttonType={secondaryButtonType || 'primary'}\n\t\t\t\t\t\tbuttonText={secondaryButtonText || 'Clear'}\n\t\t\t\t\t\tonClick={onClear}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t<Button\n\t\t\t\t\tsize=\"small\"\n\t\t\t\t\tbuttonText={primaryButtonText || buttonText || 'Apply'}\n\t\t\t\t\tbuttonType={primaryButtonType || 'primary'}\n\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\tonApply();\n\t\t\t\t\t}}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</BottomBarContainer>\n\t);\n};\n\nexport default MultiSelectDropdownBottomBar;\n"],"names":["MultiSelectDropdownBottomBar","props","onClear","onApply","list","buttonText","buttonOptions","hideClearButton","primaryButtonText","primaryButtonType","secondaryButtonText","secondaryButtonType","count","total","option","groupedTotal","op","BottomBarContainer","jsx","BodySecondary","COLORS","jsxs","Button"],"mappings":";;;;;AAoBA,MAAMA,IAEF,CAACC,MAAU;AACd,QAAM,EAAE,SAAAC,GAAS,SAAAC,GAAS,MAAAC,GAAM,YAAAC,GAAY,eAAAC,GAAe,iBAAAC,MAC1DN,GACK;AAAA,IACL,mBAAAO;AAAA,IACA,mBAAAC;AAAA,IACA,qBAAAC;AAAA,IACA,qBAAAC;AAAA,EAAA,IACGL,KAAiB,CAAA,GACfM,IAAQR,EAAK,OAAO,CAACS,GAAOC,MAAW;AAC5C,QAAKA,EAAyB,SAAS;AACtC,YAAMC,IAAgBD,EAAyB,QAAQ;AAAA,QACtD,CAACE,MAAOA,EAAG,aAAa;AAAA,MAAA,EACvB;AACF,aAAOH,IAAQE;AAAA,IAChB;AAEA,WAAQD,EAAwB,WAAWD,IAAQ,IAAIA;AAAA,EACxD,GAAG,CAAC;AAEJ,2BACEI,GAAA,EAAmB,OAAO,EAAE,gBAAgB,mBAC5C,UAAA;AAAA,IAAA,gBAAAC,EAACC,GAAA,EAAc,OAAO,EAAE,MAAM,GAAG,OAAOC,EAAO,QAAQ,QAAA,GACrD,UAAAR,IAAQ,GAAGA,CAAK,cAAc,IAChC;AAAA,IAEA,gBAAAS,EAAC,OAAA,EAAI,OAAO,EAAE,eAAe,OAAO,SAAS,QAAQ,KAAK,GAAA,GACxD,UAAA;AAAA,MAAA,CAACd,KACD,gBAAAW;AAAA,QAACI;AAAA,QAAA;AAAA,UACA,MAAK;AAAA,UACL,YAAYX,KAAuB;AAAA,UACnC,YAAYD,KAAuB;AAAA,UACnC,SAASR;AAAA,QAAA;AAAA,MAAA;AAAA,MAGX,gBAAAgB;AAAA,QAACI;AAAA,QAAA;AAAA,UACA,MAAK;AAAA,UACL,YAAYd,KAAqBH,KAAc;AAAA,UAC/C,YAAYI,KAAqB;AAAA,UACjC,SAAS,MAAM;AACd,YAAAN,EAAA;AAAA,UACD;AAAA,QAAA;AAAA,MAAA;AAAA,IACD,EAAA,CACD;AAAA,EAAA,GACD;AAEF;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DropdownOption, SingleOption } from '../../type';
|
|
2
|
-
export declare function iterateOnOptions(options: DropdownOption[], newVal: Partial<SingleOption>, checkCB?: (optionForValidation: SingleOption) => boolean
|
|
3
|
-
options: SingleOption[];
|
|
2
|
+
export declare function iterateOnOptions(options: DropdownOption[], newVal: Partial<SingleOption>, checkCB?: (optionForValidation: SingleOption) => boolean): ({
|
|
4
3
|
label: string;
|
|
5
4
|
value: string;
|
|
6
5
|
description?: string | null | undefined;
|
|
@@ -18,25 +17,24 @@ export declare function iterateOnOptions(options: DropdownOption[], newVal: Part
|
|
|
18
17
|
'data-test'?: string | undefined;
|
|
19
18
|
hasDivider?: boolean | undefined;
|
|
20
19
|
} | {
|
|
21
|
-
options: SingleOption[];
|
|
22
20
|
label?: string | undefined;
|
|
21
|
+
value?: string | undefined;
|
|
22
|
+
description?: string | null | undefined;
|
|
23
|
+
selected?: boolean | undefined;
|
|
24
|
+
disabled?: boolean | undefined;
|
|
25
|
+
isFreeForm?: boolean | undefined;
|
|
26
|
+
subText?: string | undefined;
|
|
27
|
+
trailingIcon?: JSX.Element | undefined;
|
|
23
28
|
leadingIcon?: JSX.Element | undefined;
|
|
29
|
+
customComponent?: JSX.Element | undefined;
|
|
30
|
+
searchKey?: string | undefined;
|
|
31
|
+
selectedLabel?: string | undefined;
|
|
32
|
+
children?: SingleOption[] | undefined;
|
|
33
|
+
parent?: SingleOption | undefined;
|
|
34
|
+
'data-test'?: string | undefined;
|
|
35
|
+
hasDivider?: boolean | undefined;
|
|
36
|
+
options: SingleOption[];
|
|
24
37
|
})[];
|
|
25
38
|
export declare function iterateOnOptionsRaw(options: DropdownOption[], cb: (option: SingleOption) => void): void;
|
|
26
39
|
export declare function getSelectedOptionsAsText(selectedOption: DropdownOption[]): string | undefined;
|
|
27
40
|
export declare function getSelectedOptionsAsArray(selectedOption: DropdownOption[]): string[];
|
|
28
|
-
export declare function getNestedParentValues(options: DropdownOption[]): string[];
|
|
29
|
-
/**
|
|
30
|
-
* Selectable rows in the order they are rendered, so keyboard focus indices line
|
|
31
|
-
* up with the rows MenuList numbers - otherwise arrow keys highlight one option
|
|
32
|
-
* while Enter toggles another.
|
|
33
|
-
*/
|
|
34
|
-
export declare function flattenSelectableOptions(options: DropdownOption[], nestedChildren?: {
|
|
35
|
-
collapsedParents: string[];
|
|
36
|
-
}): SingleOption[];
|
|
37
|
-
/**
|
|
38
|
-
* The rows a selection count is about. Only the nested layout makes children
|
|
39
|
-
* selectable - in the flyout layout a submenu click marks the parent, so the
|
|
40
|
-
* parent stays the row that counts. Disabled rows are kept for the caller to filter.
|
|
41
|
-
*/
|
|
42
|
-
export declare function getSelectionLeaves(options: DropdownOption[], nestedChildren?: boolean): SingleOption[];
|
|
@@ -1,82 +1,36 @@
|
|
|
1
|
-
function
|
|
2
|
-
return
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
selected: l.length ? l.every((r) => r.selected) : n.selected
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function i(n, s, e, t = !1) {
|
|
22
|
-
const l = (r) => !e || e(r) ? a(r, s, t) : t && r.children?.length ? u(r, s, e) : { ...r };
|
|
23
|
-
return n.map((r) => r.options ? {
|
|
24
|
-
...r,
|
|
25
|
-
options: r.options.map(l)
|
|
26
|
-
} : l(r));
|
|
1
|
+
function o(t, r, n) {
|
|
2
|
+
return t.map((e) => {
|
|
3
|
+
if (e.options) {
|
|
4
|
+
const i = e.options.map((s) => !n || n(s) ? {
|
|
5
|
+
...s,
|
|
6
|
+
...r
|
|
7
|
+
} : { ...s });
|
|
8
|
+
return {
|
|
9
|
+
...e,
|
|
10
|
+
options: [...i]
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
return !n || n(e) ? {
|
|
14
|
+
...e,
|
|
15
|
+
...r
|
|
16
|
+
} : { ...e };
|
|
17
|
+
});
|
|
27
18
|
}
|
|
28
|
-
function f(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
n.forEach((t) => {
|
|
33
|
-
t.options ? t.options.forEach(e) : e(t);
|
|
19
|
+
function f(t, r) {
|
|
20
|
+
t.forEach((n) => {
|
|
21
|
+
n.options ? n.options.forEach(r) : r(n);
|
|
34
22
|
});
|
|
35
23
|
}
|
|
36
|
-
function
|
|
37
|
-
if (!(!
|
|
38
|
-
return
|
|
39
|
-
const
|
|
40
|
-
return
|
|
24
|
+
function a(t) {
|
|
25
|
+
if (!(!t || !t.length))
|
|
26
|
+
return t.map((r) => {
|
|
27
|
+
const n = r;
|
|
28
|
+
return n.selectedLabel ?? n.label;
|
|
41
29
|
}).join(", ");
|
|
42
30
|
}
|
|
43
|
-
function h(n) {
|
|
44
|
-
return n.filter((s) => s.children?.length).map((s) => s.value);
|
|
45
|
-
}
|
|
46
|
-
function d(n, s) {
|
|
47
|
-
const e = [];
|
|
48
|
-
return n.forEach((t) => {
|
|
49
|
-
if (t.options) {
|
|
50
|
-
t.options.forEach((r) => {
|
|
51
|
-
r.disabled || e.push(r);
|
|
52
|
-
});
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const l = t;
|
|
56
|
-
l.disabled || e.push(l), !(!s || s.collapsedParents.includes(l.value)) && l.children?.forEach((r) => {
|
|
57
|
-
r.disabled || e.push(r);
|
|
58
|
-
});
|
|
59
|
-
}), e;
|
|
60
|
-
}
|
|
61
|
-
function o(n, s = !1) {
|
|
62
|
-
const e = [];
|
|
63
|
-
return n.forEach((t) => {
|
|
64
|
-
if (t.options) {
|
|
65
|
-
e.push(...t.options);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
const l = t;
|
|
69
|
-
e.push(
|
|
70
|
-
...s && l.children?.length ? l.children : [l]
|
|
71
|
-
);
|
|
72
|
-
}), e;
|
|
73
|
-
}
|
|
74
31
|
export {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
c as getSelectedOptionsAsText,
|
|
78
|
-
o as getSelectionLeaves,
|
|
79
|
-
i as iterateOnOptions,
|
|
32
|
+
a as getSelectedOptionsAsText,
|
|
33
|
+
o as iterateOnOptions,
|
|
80
34
|
f as iterateOnOptionsRaw
|
|
81
35
|
};
|
|
82
36
|
//# sourceMappingURL=iterationOnOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iterationOnOptions.js","sources":["../../../../../../src/components/dropdown/OpenedDropdown/utils/iterationOnOptions.ts"],"sourcesContent":["import { DropdownOption, GroupedOption, SingleOption } from '../../type';\n\
|
|
1
|
+
{"version":3,"file":"iterationOnOptions.js","sources":["../../../../../../src/components/dropdown/OpenedDropdown/utils/iterationOnOptions.ts"],"sourcesContent":["import { DropdownOption, GroupedOption, SingleOption } from '../../type';\n\nexport function iterateOnOptions(\n\toptions: DropdownOption[],\n\tnewVal: Partial<SingleOption>,\n\tcheckCB?: (optionForValidation: SingleOption) => boolean,\n) {\n\tconst newOptions = options.map((option) => {\n\t\tif ((option as GroupedOption).options) {\n\t\t\tconst groupedOptions = (option as GroupedOption).options.map((op) => {\n\t\t\t\tif (!checkCB || checkCB(op)) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...op,\n\t\t\t\t\t\t...newVal,\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn { ...op };\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\t...option,\n\t\t\t\toptions: [...groupedOptions],\n\t\t\t};\n\t\t}\n\n\t\tif (!checkCB || checkCB(option as SingleOption)) {\n\t\t\treturn {\n\t\t\t\t...option,\n\t\t\t\t...newVal,\n\t\t\t};\n\t\t}\n\n\t\treturn { ...option };\n\t});\n\n\treturn newOptions;\n}\n\nexport function iterateOnOptionsRaw(\n\toptions: DropdownOption[],\n\tcb: (option: SingleOption) => void,\n) {\n\toptions.forEach((option) => {\n\t\tif ((option as GroupedOption).options) {\n\t\t\t(option as GroupedOption).options.forEach(cb);\n\t\t} else {\n\t\t\tcb(option as SingleOption);\n\t\t}\n\t});\n}\n\nexport function getSelectedOptionsAsText(selectedOption: DropdownOption[]) {\n\tif (!selectedOption || !selectedOption.length) return undefined;\n\treturn selectedOption\n\t\t.map((option) => {\n\t\t\tconst op = option as SingleOption;\n\t\t\treturn op.selectedLabel ?? op.label;\n\t\t})\n\t\t.join(', ');\n}\n\n// get selected options as array of string\nexport function getSelectedOptionsAsArray(selectedOption: DropdownOption[]) {\n\tif (!selectedOption || !selectedOption.length) return [];\n\treturn selectedOption.map((option) => {\n\t\tconst op = option as SingleOption;\n\t\treturn op.selectedLabel ?? op.label;\n\t});\n}\n"],"names":["iterateOnOptions","options","newVal","checkCB","option","groupedOptions","op","iterateOnOptionsRaw","cb","getSelectedOptionsAsText","selectedOption"],"mappings":"AAEO,SAASA,EACfC,GACAC,GACAC,GACC;AA8BD,SA7BmBF,EAAQ,IAAI,CAACG,MAAW;AAC1C,QAAKA,EAAyB,SAAS;AACtC,YAAMC,IAAkBD,EAAyB,QAAQ,IAAI,CAACE,MACzD,CAACH,KAAWA,EAAQG,CAAE,IAClB;AAAA,QACN,GAAGA;AAAA,QACH,GAAGJ;AAAA,MAAA,IAIE,EAAE,GAAGI,EAAA,CACZ;AAED,aAAO;AAAA,QACN,GAAGF;AAAA,QACH,SAAS,CAAC,GAAGC,CAAc;AAAA,MAAA;AAAA,IAE7B;AAEA,WAAI,CAACF,KAAWA,EAAQC,CAAsB,IACtC;AAAA,MACN,GAAGA;AAAA,MACH,GAAGF;AAAA,IAAA,IAIE,EAAE,GAAGE,EAAA;AAAA,EACb,CAAC;AAGF;AAEO,SAASG,EACfN,GACAO,GACC;AACD,EAAAP,EAAQ,QAAQ,CAACG,MAAW;AAC3B,IAAKA,EAAyB,UAC5BA,EAAyB,QAAQ,QAAQI,CAAE,IAE5CA,EAAGJ,CAAsB;AAAA,EAE3B,CAAC;AACF;AAEO,SAASK,EAAyBC,GAAkC;AAC1E,MAAI,GAACA,KAAkB,CAACA,EAAe;AACvC,WAAOA,EACL,IAAI,CAACN,MAAW;AAChB,YAAME,IAAKF;AACX,aAAOE,EAAG,iBAAiBA,EAAG;AAAA,IAC/B,CAAC,EACA,KAAK,IAAI;AACZ;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SelectAllCheckboxState } from '../OpenedDropdown/components/menu/SelectAllMenu';
|
|
2
2
|
import { DropdownOption, SingleOption } from '../type';
|
|
3
|
-
export declare const useDropdown: (version: string | undefined, options: DropdownOption[], onSelect: ((option: DropdownOption | DropdownOption[]) => void) | undefined, skipSorting?: boolean, isMultiSelect?: boolean, onSearch?: ((searchKey: string) => Promise<DropdownOption[]>) | undefined, disableOtherSearchedOption?: boolean, disableSearchedOptionExcept?: string[], maxSelections?: number
|
|
3
|
+
export declare const useDropdown: (version: string | undefined, options: DropdownOption[], onSelect: ((option: DropdownOption | DropdownOption[]) => void) | undefined, skipSorting?: boolean, isMultiSelect?: boolean, onSearch?: ((searchKey: string) => Promise<DropdownOption[]>) | undefined, disableOtherSearchedOption?: boolean, disableSearchedOptionExcept?: string[], maxSelections?: number) => {
|
|
4
4
|
latestDropdownOptionsRef: import('react').MutableRefObject<DropdownOption[]>;
|
|
5
5
|
dropdownOptions: DropdownOption[];
|
|
6
6
|
search: (searchKey: string) => void;
|
|
@@ -8,8 +8,7 @@ export declare const useDropdown: (version: string | undefined, options: Dropdow
|
|
|
8
8
|
searchedOptions: DropdownOption[];
|
|
9
9
|
searchError: string | undefined;
|
|
10
10
|
retrySearch: () => void;
|
|
11
|
-
onApplyHandler: (optionSelect: SingleOption, returnOnly?: boolean) => (
|
|
12
|
-
options: SingleOption[];
|
|
11
|
+
onApplyHandler: (optionSelect: SingleOption, returnOnly?: boolean) => ({
|
|
13
12
|
label: string;
|
|
14
13
|
value: string;
|
|
15
14
|
description?: string | null | undefined;
|
|
@@ -27,9 +26,23 @@ export declare const useDropdown: (version: string | undefined, options: Dropdow
|
|
|
27
26
|
'data-test'?: string | undefined;
|
|
28
27
|
hasDivider?: boolean | undefined;
|
|
29
28
|
} | {
|
|
30
|
-
options: SingleOption[];
|
|
31
29
|
label?: string | undefined;
|
|
30
|
+
value?: string | undefined;
|
|
31
|
+
description?: string | null | undefined;
|
|
32
|
+
selected?: boolean | undefined;
|
|
33
|
+
disabled?: boolean | undefined;
|
|
34
|
+
isFreeForm?: boolean | undefined;
|
|
35
|
+
subText?: string | undefined;
|
|
36
|
+
trailingIcon?: JSX.Element | undefined;
|
|
32
37
|
leadingIcon?: JSX.Element | undefined;
|
|
38
|
+
customComponent?: JSX.Element | undefined;
|
|
39
|
+
searchKey?: string | undefined;
|
|
40
|
+
selectedLabel?: string | undefined;
|
|
41
|
+
children?: SingleOption[] | undefined;
|
|
42
|
+
parent?: SingleOption | undefined;
|
|
43
|
+
'data-test'?: string | undefined;
|
|
44
|
+
hasDivider?: boolean | undefined;
|
|
45
|
+
options: SingleOption[];
|
|
33
46
|
})[] | undefined;
|
|
34
47
|
selectAllHandler: (newState: SelectAllCheckboxState) => void;
|
|
35
48
|
onMultiSelectClear: () => void;
|