@dfx.swiss/react-components 1.1.3-beta.2 → 1.1.3-beta.4
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/stories/form/StyledDropdown.d.ts +3 -1
- package/dist/stories/form/StyledDropdown.d.ts.map +1 -1
- package/dist/stories/form/StyledDropdown.js +3 -3
- package/dist/stories/form/StyledDropdown.js.map +1 -1
- package/dist/stories/form/StyledModalButton.d.ts +4 -5
- package/dist/stories/form/StyledModalButton.d.ts.map +1 -1
- package/dist/stories/form/StyledModalButton.js +2 -2
- package/dist/stories/form/StyledModalButton.js.map +1 -1
- package/dist/stories/form/StyledModalDropdown.d.ts +1 -1
- package/dist/stories/form/StyledModalDropdown.d.ts.map +1 -1
- package/dist/stories/form/StyledModalDropdown.js +2 -2
- package/dist/stories/form/StyledModalDropdown.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ControlProps } from './Form';
|
|
2
|
+
import { RefObject } from 'react';
|
|
2
3
|
import { IconVariant } from '../DfxIcon';
|
|
3
4
|
import { AssetIconVariant } from '../DfxAssetIcon';
|
|
4
5
|
export interface StyledDropdownProps<T> extends ControlProps {
|
|
@@ -12,6 +13,7 @@ export interface StyledDropdownProps<T> extends ControlProps {
|
|
|
12
13
|
descriptionFunc?: (item: T) => string;
|
|
13
14
|
priceFunc?: (item: T) => string;
|
|
14
15
|
assetIconFunc?: (item: T) => AssetIconVariant;
|
|
16
|
+
rootRef?: RefObject<HTMLElement>;
|
|
15
17
|
}
|
|
16
|
-
export default function StyledDropdown<T>({ label, labelIcon, control, name, rules, disabled, items, placeholder, full, smallLabel, labelFunc, balanceFunc, descriptionFunc, priceFunc, assetIconFunc, ...props }: StyledDropdownProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export default function StyledDropdown<T>({ label, labelIcon, control, name, rules, disabled, items, placeholder, full, smallLabel, labelFunc, balanceFunc, descriptionFunc, priceFunc, assetIconFunc, rootRef, ...props }: StyledDropdownProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
17
19
|
//# sourceMappingURL=StyledDropdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyledDropdown.d.ts","sourceRoot":"","sources":["../../../src/stories/form/StyledDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"StyledDropdown.d.ts","sourceRoot":"","sources":["../../../src/stories/form/StyledDropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,SAAS,EAA+B,MAAM,OAAO,CAAC;AAC/D,OAAgB,EAAuB,WAAW,EAAE,MAAM,YAAY,CAAC;AAEvE,OAAqB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGjE,MAAM,WAAW,mBAAmB,CAAC,CAAC,CAAE,SAAQ,YAAY;IAC1D,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,CAAC,EAAE,CAAC;IACX,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAC/B,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAClC,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IACtC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAChC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,gBAAgB,CAAC;IAC9C,OAAO,CAAC,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;CAClC;AAED,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,CAAC,EAAE,EACxC,KAAK,EACL,SAAS,EACT,OAAO,EACP,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,KAAK,EACL,WAAW,EACX,IAAI,EACJ,UAAU,EACV,SAAS,EACT,WAAW,EACX,eAAe,EACf,SAAS,EACT,aAAa,EACb,OAAO,EACP,GAAG,KAAK,EACT,EAAE,mBAAmB,CAAC,CAAC,CAAC,2CA6HxB"}
|
|
@@ -21,19 +21,20 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
23
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
24
|
-
import { useRef, useState } from 'react';
|
|
24
|
+
import { useEffect, useRef, useState } from 'react';
|
|
25
25
|
import DfxIcon, { IconColor, IconSize, IconVariant } from '../DfxIcon';
|
|
26
26
|
import { Controller } from 'react-hook-form';
|
|
27
27
|
import DfxAssetIcon from '../DfxAssetIcon';
|
|
28
28
|
import { Utils } from '../../utils';
|
|
29
29
|
export default function StyledDropdown(_a) {
|
|
30
|
-
var label = _a.label, labelIcon = _a.labelIcon, control = _a.control, name = _a.name, rules = _a.rules, disabled = _a.disabled, items = _a.items, placeholder = _a.placeholder, full = _a.full, smallLabel = _a.smallLabel, labelFunc = _a.labelFunc, balanceFunc = _a.balanceFunc, descriptionFunc = _a.descriptionFunc, priceFunc = _a.priceFunc, assetIconFunc = _a.assetIconFunc, props = __rest(_a, ["label", "labelIcon", "control", "name", "rules", "disabled", "items", "placeholder", "full", "smallLabel", "labelFunc", "balanceFunc", "descriptionFunc", "priceFunc", "assetIconFunc"]);
|
|
30
|
+
var label = _a.label, labelIcon = _a.labelIcon, control = _a.control, name = _a.name, rules = _a.rules, disabled = _a.disabled, items = _a.items, placeholder = _a.placeholder, full = _a.full, smallLabel = _a.smallLabel, labelFunc = _a.labelFunc, balanceFunc = _a.balanceFunc, descriptionFunc = _a.descriptionFunc, priceFunc = _a.priceFunc, assetIconFunc = _a.assetIconFunc, rootRef = _a.rootRef, props = __rest(_a, ["label", "labelIcon", "control", "name", "rules", "disabled", "items", "placeholder", "full", "smallLabel", "labelFunc", "balanceFunc", "descriptionFunc", "priceFunc", "assetIconFunc", "rootRef"]);
|
|
31
31
|
var buttonRef = useRef(null);
|
|
32
32
|
var dropdownRef = useRef(null);
|
|
33
33
|
var _b = useState(false), isOpen = _b[0], setIsOpen = _b[1];
|
|
34
34
|
var buttonClasses = 'flex justify-between border border-dfxGray-500 px-4 py-3 shadow-sm w-full';
|
|
35
35
|
isOpen ? (buttonClasses += ' rounded-x rounded-t bg-dfxGray-400/50') : (buttonClasses += ' rounded');
|
|
36
36
|
var isDisabled = disabled || items.length <= 1;
|
|
37
|
+
useEffect(function () { var _a; return (_a = rootRef === null || rootRef === void 0 ? void 0 : rootRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('mousedown', closeDropdown); }, [rootRef, rootRef === null || rootRef === void 0 ? void 0 : rootRef.current, isOpen]);
|
|
37
38
|
function closeDropdown(e) {
|
|
38
39
|
if (isOpen &&
|
|
39
40
|
Utils.isNode(e.target) &&
|
|
@@ -44,7 +45,6 @@ export default function StyledDropdown(_a) {
|
|
|
44
45
|
setIsOpen(false);
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
|
-
document.addEventListener('mousedown', closeDropdown);
|
|
48
48
|
return (_jsx(Controller, { control: control, render: function (_a) {
|
|
49
49
|
var _b = _a.field, onChange = _b.onChange, onBlur = _b.onBlur, value = _b.value;
|
|
50
50
|
return (_jsxs("div", __assign({ className: "relative ".concat(full ? 'w-full' : '') }, { children: [_jsxs("div", __assign({ className: "flex items-center ml-3.5 mb-2.5" }, { children: [labelIcon !== undefined && _jsx(DfxIcon, { icon: labelIcon, size: IconSize.SM, color: IconColor.BLUE }), _jsx("label", __assign({ className: "text-dfxBlue-800 ".concat(smallLabel ? 'text-sm' : 'text-base', " font-semibold ").concat(labelIcon ? 'pl-3.5' : '') }, { children: label }))] })), _jsxs("button", __assign({ ref: buttonRef, id: "dropDownButton", type: "button", onClick: function () { return setIsOpen(!isOpen); }, className: buttonClasses, onBlur: onBlur, disabled: isDisabled }, props, { children: [_jsxs("div", __assign({ className: "flex flex-row gap-2 items-center w-full" }, { children: [value && assetIconFunc && _jsx(DfxAssetIcon, { asset: assetIconFunc(value) }), _jsx("div", __assign({ className: "flex flex-col gap-1 justify-between text-left w-full" }, { children: value === undefined ? (_jsx("p", __assign({ className: "text-dfxGray-600 drop-shadow-none py-[0.25rem]" }, { children: placeholder }))) : (_jsxs(_Fragment, { children: [_jsxs("span", __assign({ className: "text-dfxBlue-800 leading-none font-semibold flex justify-between ".concat(!descriptionFunc && !assetIconFunc ? 'py-[0.25rem]' : '') }, { children: [labelFunc(value), balanceFunc && _jsx("p", { children: balanceFunc(value) })] })), descriptionFunc && (_jsxs("span", __assign({ className: "text-dfxGray-800 text-xs h-min leading-none flex justify-between" }, { children: [descriptionFunc(value), priceFunc && _jsx("p", { children: priceFunc(value) })] })))] })) }))] })), !isDisabled && (_jsx("div", __assign({ className: "place-self-center" }, { children: _jsx(DfxIcon, { icon: isOpen ? IconVariant.EXPAND_LESS : IconVariant.EXPAND_MORE, size: IconSize.LG }) })))] })), isOpen && (_jsx("div", __assign({ ref: dropdownRef, className: "absolute bg-white rounded-b w-full z-10 max-h-40 overflow-y-auto" }, { children: items.map(function (item, index) { return (_jsx("button", __assign({ onClick: function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyledDropdown.js","sourceRoot":"","sources":["../../../src/stories/form/StyledDropdown.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"StyledDropdown.js","sourceRoot":"","sources":["../../../src/stories/form/StyledDropdown.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EA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C,qJAAqJ,gBAE/J,wBAAK,SAAS,EAAC,yCAAyC,iBACrD,aAAa,IAAI,KAAC,YAAY,IAAC,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,GAAI,EAC9D,wBAAK,SAAS,EAAC,sDAAsD,iBACnE,yBACE,SAAS,EAAE,2EACT,CAAC,eAAe,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CACxD,iBAED,SAAS,CAAC,IAAI,CAAC,EACf,WAAW,IAAI,sBAAI,WAAW,CAAC,IAAI,CAAC,GAAK,KACrC,EACN,eAAe,IAAI,CAClB,yBAAM,SAAS,EAAC,kEAAkE,iBAC/E,eAAe,CAAC,IAAI,CAAC,EACrB,SAAS,IAAI,sBAAI,SAAS,CAAC,IAAI,CAAC,GAAK,KACjC,CACR,KACG,KACF,KAzBD,KAAK,CA0BH,CACV,EA7B2B,CA6B3B,CAAC,IACE,CACP,KACG,CACP;QA1FmD,CA0FnD,EACD,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,GACZ,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Noop } from 'react-hook-form';
|
|
3
|
-
export interface StyledModalButtonProps
|
|
3
|
+
export interface StyledModalButtonProps {
|
|
4
4
|
label?: string;
|
|
5
5
|
onClick: () => void;
|
|
6
6
|
onBlur: Noop;
|
|
7
|
-
value
|
|
8
|
-
|
|
9
|
-
labelFunc: (item: T) => string;
|
|
7
|
+
value?: string;
|
|
8
|
+
description?: string;
|
|
10
9
|
placeholder: string;
|
|
11
10
|
}
|
|
12
|
-
export default function StyledModalButton
|
|
11
|
+
export default function StyledModalButton({ label, onClick, onBlur, value, description, placeholder, ...props }: StyledModalButtonProps): JSX.Element;
|
|
13
12
|
//# sourceMappingURL=StyledModalButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyledModalButton.d.ts","sourceRoot":"","sources":["../../../src/stories/form/StyledModalButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAIvC,MAAM,WAAW,sBAAsB
|
|
1
|
+
{"version":3,"file":"StyledModalButton.d.ts","sourceRoot":"","sources":["../../../src/stories/form/StyledModalButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAIvC,MAAM,WAAW,sBAAsB;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,EAAE,IAAI,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,KAAK,EACL,OAAO,EACP,MAAM,EACN,KAAK,EACL,WAAW,EACX,WAAW,EACX,GAAG,KAAK,EACT,EAAE,sBAAsB,GAAG,GAAG,CAAC,OAAO,CA4BtC"}
|
|
@@ -24,7 +24,7 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
24
24
|
import StyledVerticalStack from '../layout-helpers/StyledVerticalStack';
|
|
25
25
|
import DfxIcon, { IconSize, IconVariant } from '../DfxIcon';
|
|
26
26
|
export default function StyledModalButton(_a) {
|
|
27
|
-
var label = _a.label, onClick = _a.onClick, onBlur = _a.onBlur, value = _a.value,
|
|
28
|
-
return (_jsxs(StyledVerticalStack, __assign({ gap: 1, marginY: 4 }, { children: [_jsx("label", __assign({ className: "text-dfxBlue-800 text-base font-semibold pl-4 text-start" }, { children: label })), _jsxs("button", __assign({ className: "flex justify-between border border-dfxGray-400 text-base font-normal rounded-md px-4 py-2 shadow-sm w-full", onClick: onClick, onBlur: onBlur }, props, { children: [_jsx("div", __assign({ className: "flex flex-col justify-between text-left gap-1" }, { children: value ? (_jsxs(_Fragment, { children: [
|
|
27
|
+
var label = _a.label, onClick = _a.onClick, onBlur = _a.onBlur, value = _a.value, description = _a.description, placeholder = _a.placeholder, props = __rest(_a, ["label", "onClick", "onBlur", "value", "description", "placeholder"]);
|
|
28
|
+
return (_jsxs(StyledVerticalStack, __assign({ gap: 1, marginY: 4 }, { children: [_jsx("label", __assign({ className: "text-dfxBlue-800 text-base font-semibold pl-4 text-start" }, { children: label })), _jsxs("button", __assign({ className: "flex justify-between border border-dfxGray-400 text-base font-normal rounded-md px-4 py-2 shadow-sm w-full", onClick: onClick, onBlur: onBlur }, props, { children: [_jsx("div", __assign({ className: "flex flex-col justify-between text-left gap-1" }, { children: value ? (_jsxs(_Fragment, { children: [description && _jsx("span", __assign({ className: "text-dfxGray-800 text-xs h-min leading-none" }, { children: description })), _jsx("span", __assign({ className: 'text-dfxBlue-800 leading-none font-base'.concat(description ? '' : ' py-2') }, { children: value }))] })) : (_jsx("span", __assign({ className: "text-dfxGray-600 py-1" }, { children: placeholder }))) })), _jsx("div", __assign({ className: "place-self-center" }, { children: _jsx(DfxIcon, { icon: IconVariant.UNFOLD_MORE, size: IconSize.LG }) }))] }))] })));
|
|
29
29
|
}
|
|
30
30
|
//# sourceMappingURL=StyledModalButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyledModalButton.js","sourceRoot":"","sources":["../../../src/stories/form/StyledModalButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,mBAAmB,MAAM,uCAAuC,CAAC;AACxE,OAAO,OAAO,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"StyledModalButton.js","sourceRoot":"","sources":["../../../src/stories/form/StyledModalButton.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,mBAAmB,MAAM,uCAAuC,CAAC;AACxE,OAAO,OAAO,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAW5D,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EAQjB;IAPvB,IAAA,KAAK,WAAA,EACL,OAAO,aAAA,EACP,MAAM,YAAA,EACN,KAAK,WAAA,EACL,WAAW,iBAAA,EACX,WAAW,iBAAA,EACR,KAAK,cAPgC,qEAQzC,CADS;IAER,OAAO,CACL,MAAC,mBAAmB,aAAC,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,iBACrC,yBAAO,SAAS,EAAC,0DAA0D,gBAAE,KAAK,IAAS,EAC3F,2BACE,SAAS,EAAC,4GAA4G,EACtH,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,IACV,KAAK,eAET,uBAAK,SAAS,EAAC,+CAA+C,gBAC3D,KAAK,CAAC,CAAC,CAAC,CACP,8BACG,WAAW,IAAI,wBAAM,SAAS,EAAC,6CAA6C,gBAAE,WAAW,IAAQ,EAClG,wBAAM,SAAS,EAAE,yCAAyC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,gBAC1F,KAAK,IACD,IACN,CACJ,CAAC,CAAC,CAAC,CACF,wBAAM,SAAS,EAAC,uBAAuB,gBAAE,WAAW,IAAQ,CAC7D,IACG,EACN,uBAAK,SAAS,EAAC,mBAAmB,gBAChC,KAAC,OAAO,IAAC,IAAI,EAAE,WAAW,CAAC,WAAW,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,GAAI,IACzD,KACC,KACW,CACvB,CAAC;AACJ,CAAC"}
|
|
@@ -13,6 +13,6 @@ interface StyledModalDropdownProps<T> extends ControlProps {
|
|
|
13
13
|
form?: (onFormSubmit: (item: T) => void) => JSX.Element;
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
export default function StyledModalDropdown<T>({ control, name, label, rules, modal, ...props }: StyledModalDropdownProps<T>): JSX.Element;
|
|
16
|
+
export default function StyledModalDropdown<T>({ control, name, label, rules, modal, labelFunc, descriptionFunc, ...props }: StyledModalDropdownProps<T>): JSX.Element;
|
|
17
17
|
export {};
|
|
18
18
|
//# sourceMappingURL=StyledModalDropdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyledModalDropdown.d.ts","sourceRoot":"","sources":["../../../src/stories/form/StyledModalDropdown.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"StyledModalDropdown.d.ts","sourceRoot":"","sources":["../../../src/stories/form/StyledModalDropdown.tsx"],"names":[],"mappings":";AAGA,OAAoB,EAAoB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,UAAU,wBAAwB,CAAC,CAAC,CAAE,SAAQ,YAAY;IACxD,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;IAC/B,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,SAAS,CAAC;IAClD,KAAK,EAAE;QACL,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,CAAC,EAAE,CAAC;QACX,KAAK,CAAC,EAAE,gBAAgB,CAAC;QACzB,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC;QACtC,IAAI,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,KAAK,GAAG,CAAC,OAAO,CAAC;KACzD,CAAC;CACH;AAED,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,CAAC,EAAE,EAC7C,OAAO,EACP,IAAI,EACJ,KAAK,EACL,KAAK,EACL,KAAK,EACL,SAAS,EACT,eAAe,EACf,GAAG,KAAK,EACT,EAAE,wBAAwB,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,CA4D3C"}
|
|
@@ -27,7 +27,7 @@ import StyledVerticalStack from '../layout-helpers/StyledVerticalStack';
|
|
|
27
27
|
import StyledModal, { StyledModalColor, StyledModalWidth } from '../StyledModal';
|
|
28
28
|
import StyledModalButton from './StyledModalButton';
|
|
29
29
|
export default function StyledModalDropdown(_a) {
|
|
30
|
-
var control = _a.control, name = _a.name, label = _a.label, rules = _a.rules, modal = _a.modal, props = __rest(_a, ["control", "name", "label", "rules", "modal"]);
|
|
30
|
+
var control = _a.control, name = _a.name, label = _a.label, rules = _a.rules, modal = _a.modal, labelFunc = _a.labelFunc, descriptionFunc = _a.descriptionFunc, props = __rest(_a, ["control", "name", "label", "rules", "modal", "labelFunc", "descriptionFunc"]);
|
|
31
31
|
var _b = useState(false), showModal = _b[0], setShowModal = _b[1];
|
|
32
32
|
return (_jsx(Controller, { control: control, render: function (_a) {
|
|
33
33
|
var _b = _a.field, onChange = _b.onChange, onBlur = _b.onBlur, value = _b.value;
|
|
@@ -39,7 +39,7 @@ export default function StyledModalDropdown(_a) {
|
|
|
39
39
|
} }, { children: obj.content }), index)); }) }))), modal.form && (_jsxs(_Fragment, { children: [_jsx("div", { className: "h-[1px] bg-dfxGray-400 ".concat(modal.width === StyledModalWidth.NONE ? '-mx-4' : '-mx-14', " my-6") }), modal.form(function (item) {
|
|
40
40
|
onChange(item);
|
|
41
41
|
setShowModal(false);
|
|
42
|
-
})] }))] })), _jsx(StyledModalButton, __assign({ label: label, onClick: function () { return setShowModal(true); }, onBlur: onBlur, value: value }, props))] }));
|
|
42
|
+
})] }))] })), _jsx(StyledModalButton, __assign({ label: label, onClick: function () { return setShowModal(true); }, onBlur: onBlur, value: value && labelFunc(value), description: value && (descriptionFunc === null || descriptionFunc === void 0 ? void 0 : descriptionFunc(value)) }, props))] }));
|
|
43
43
|
}, name: name, rules: rules }));
|
|
44
44
|
}
|
|
45
45
|
//# sourceMappingURL=StyledModalDropdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyledModalDropdown.js","sourceRoot":"","sources":["../../../src/stories/form/StyledModalDropdown.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"StyledModalDropdown.js","sourceRoot":"","sources":["../../../src/stories/form/StyledModalDropdown.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,mBAAmB,MAAM,uCAAuC,CAAC;AACxE,OAAO,WAAW,EAAE,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEjF,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAepD,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAI,EASjB;IAR5B,IAAA,OAAO,aAAA,EACP,IAAI,UAAA,EACJ,KAAK,WAAA,EACL,KAAK,WAAA,EACL,KAAK,WAAA,EACL,SAAS,eAAA,EACT,eAAe,qBAAA,EACZ,KAAK,cARqC,8EAS9C,CADS;IAEF,IAAA,KAA4B,QAAQ,CAAC,KAAK,CAAC,EAA1C,SAAS,QAAA,EAAE,YAAY,QAAmB,CAAC;IAClD,OAAO,CACL,KAAC,UAAU,IACT,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,UAAC,EAAsC;gBAApC,aAAkC,EAAzB,QAAQ,cAAA,EAAE,MAAM,YAAA,EAAE,KAAK,WAAA;YAAS,OAAA,CAClD,8BACE,MAAC,WAAW,aACV,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,KAAK,EAAE,g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,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,GACZ,CACH,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@dfx.swiss/react-components",
|
|
4
|
-
"version": "1.1.3-beta.
|
|
4
|
+
"version": "1.1.3-beta.4",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"tailwindcss": "^3.2.4",
|
|
88
88
|
"webpack": "^5.75.0"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "b0277e9bfb12eec6cc713f8cc689d98895591c79"
|
|
91
91
|
}
|