@dfx.swiss/react-components 1.1.3-beta.2 → 1.1.3-beta.21
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/DfxAssetIcon.d.ts +1 -0
- package/dist/stories/DfxAssetIcon.d.ts.map +1 -1
- package/dist/stories/DfxAssetIcon.js +14 -0
- package/dist/stories/DfxAssetIcon.js.map +1 -1
- package/dist/stories/StyledLink.d.ts +3 -2
- package/dist/stories/StyledLink.d.ts.map +1 -1
- package/dist/stories/StyledLink.js +2 -2
- package/dist/stories/StyledLink.js.map +1 -1
- 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 +11 -5
- package/dist/stories/form/StyledDropdown.js.map +1 -1
- package/dist/stories/form/StyledInput.d.ts +2 -0
- package/dist/stories/form/StyledInput.d.ts.map +1 -1
- package/dist/stories/form/StyledInput.js +9 -20
- package/dist/stories/form/StyledInput.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,9 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { HTMLAttributeAnchorTarget } from 'react';
|
|
2
2
|
interface StyledLinkProps {
|
|
3
3
|
label: string;
|
|
4
4
|
url?: string;
|
|
5
5
|
dark?: boolean;
|
|
6
|
+
target?: HTMLAttributeAnchorTarget;
|
|
6
7
|
}
|
|
7
|
-
export declare function StyledLink({ label, url, dark }: StyledLinkProps): JSX.Element;
|
|
8
|
+
export declare function StyledLink({ label, url, dark, target }: StyledLinkProps): JSX.Element;
|
|
8
9
|
export {};
|
|
9
10
|
//# sourceMappingURL=StyledLink.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyledLink.d.ts","sourceRoot":"","sources":["../../src/stories/StyledLink.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"StyledLink.d.ts","sourceRoot":"","sources":["../../src/stories/StyledLink.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,OAAO,CAAC;AAElD,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,yBAAyB,CAAC;CACpC;AAED,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,eAAe,GAAG,GAAG,CAAC,OAAO,CAWrF"}
|
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
export function StyledLink(_a) {
|
|
14
|
-
var label = _a.label, url = _a.url, dark = _a.dark;
|
|
15
|
-
return (_jsx("a", __assign({ className: "".concat(dark ? 'text-dfxGray-800' : 'text-link opacity-30'), target:
|
|
14
|
+
var label = _a.label, url = _a.url, dark = _a.dark, target = _a.target;
|
|
15
|
+
return (_jsx("a", __assign({ className: "".concat(dark ? 'text-dfxGray-800' : 'text-link opacity-30'), target: target !== null && target !== void 0 ? target : '_blank', href: url, rel: "noopener noreferrer" }, { children: label })));
|
|
16
16
|
}
|
|
17
17
|
//# sourceMappingURL=StyledLink.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyledLink.js","sourceRoot":"","sources":["../../src/stories/StyledLink.tsx"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"StyledLink.js","sourceRoot":"","sources":["../../src/stories/StyledLink.tsx"],"names":[],"mappings":";;;;;;;;;;;;AASA,MAAM,UAAU,UAAU,CAAC,EAA6C;QAA3C,KAAK,WAAA,EAAE,GAAG,SAAA,EAAE,IAAI,UAAA,EAAE,MAAM,YAAA;IACnD,OAAO,CACL,qBACE,SAAS,EAAE,UAAG,IAAI,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,sBAAsB,CAAE,EAClE,MAAM,EAAE,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,QAAQ,EAC1B,IAAI,EAAE,GAAG,EACT,GAAG,EAAC,qBAAqB,gBAExB,KAAK,IACJ,CACL,CAAC;AACJ,CAAC"}
|
|
@@ -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,2CAyIxB"}
|
|
@@ -21,19 +21,26 @@ 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 () {
|
|
38
|
+
var element = rootRef === null || rootRef === void 0 ? void 0 : rootRef.current;
|
|
39
|
+
if (element) {
|
|
40
|
+
element.addEventListener('mousedown', closeDropdown);
|
|
41
|
+
return function () { return element.removeEventListener('mousedown', closeDropdown); };
|
|
42
|
+
}
|
|
43
|
+
}, [rootRef, isOpen]);
|
|
37
44
|
function closeDropdown(e) {
|
|
38
45
|
if (isOpen &&
|
|
39
46
|
Utils.isNode(e.target) &&
|
|
@@ -44,13 +51,12 @@ export default function StyledDropdown(_a) {
|
|
|
44
51
|
setIsOpen(false);
|
|
45
52
|
}
|
|
46
53
|
}
|
|
47
|
-
document.addEventListener('mousedown', closeDropdown);
|
|
48
54
|
return (_jsx(Controller, { control: control, render: function (_a) {
|
|
49
55
|
var _b = _a.field, onChange = _b.onChange, onBlur = _b.onBlur, value = _b.value;
|
|
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
|
|
56
|
+
return (_jsxs("div", __assign({ className: "relative ".concat(full ? 'w-full' : '') }, { children: [label && (_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 border-x border-b border-dfxGray-500 w-full z-10 overflow-y-auto", style: { maxHeight: '15rem' } }, { children: items.map(function (item, index) { return (_jsx("button", __assign({ onClick: function () {
|
|
51
57
|
onChange(item);
|
|
52
58
|
setIsOpen(false);
|
|
53
|
-
}, className: "flex flex-col gap-2 justify-between text-left
|
|
59
|
+
}, className: "flex flex-col gap-2 justify-between text-left w-full hover:bg-dfxGray-400/50 px-3.5 py-2.5" }, { children: _jsxs("div", __assign({ className: "flex flex-row gap-2 items-center w-full" }, { children: [assetIconFunc && _jsx(DfxAssetIcon, { asset: assetIconFunc(item) }), _jsxs("div", __assign({ className: "flex flex-col gap-1 justify-between text-left w-full" }, { children: [_jsxs("span", __assign({ className: "text-dfxBlue-800 leading-none font-semibold flex justify-between ".concat(!descriptionFunc && !assetIconFunc ? 'py-[0.25rem]' : '') }, { children: [labelFunc(item), balanceFunc && _jsx("p", { children: balanceFunc(item) })] })), descriptionFunc && (_jsxs("span", __assign({ className: "text-dfxGray-800 text-xs h-min leading-none flex justify-between" }, { children: [descriptionFunc(item), priceFunc && _jsx("p", { children: priceFunc(item) })] })))] }))] })) }), index)); }) })))] })));
|
|
54
60
|
}, name: name, rules: rules }));
|
|
55
61
|
}
|
|
56
62
|
//# sourceMappingURL=StyledDropdown.js.map
|
|
@@ -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,EAAa,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,OAAO,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,YAAkC,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAgBpC,MAAM,CAAC,OAAO,UAAU,cAAc,CAAI,EAkBjB;IAjBvB,IAAA,KAAK,WAAA,EACL,SAAS,eAAA,EACT,OAAO,aAAA,EACP,IAAI,UAAA,EACJ,KAAK,WAAA,EACL,QAAQ,cAAA,EACR,KAAK,WAAA,EACL,WAAW,iBAAA,EACX,IAAI,UAAA,EACJ,UAAU,gBAAA,EACV,SAAS,eAAA,EACT,WAAW,iBAAA,EACX,eAAe,qBAAA,EACf,SAAS,eAAA,EACT,aAAa,mBAAA,EACb,OAAO,aAAA,EACJ,KAAK,cAjBgC,oMAkBzC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AC,IAAI,CAAC,GAAK,KACjC,CACR,KACG,KACF,KAzBD,KAAK,CA0BH,CACV,EA7B2B,CA6B3B,CAAC,IACE,CACP,KACG,CACP;QAhGmD,CAgGnD,EACD,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,GACZ,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyledInput.d.ts","sourceRoot":"","sources":["../../../src/stories/form/StyledInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,sBAAsB,EAAE,MAAM,OAAO,CAAC;AAG3D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,UAAU,gBAAiB,SAAQ,YAAY;IAC7C,IAAI,CAAC,EAAE,sBAAsB,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;
|
|
1
|
+
{"version":3,"file":"StyledInput.d.ts","sourceRoot":"","sources":["../../../src/stories/form/StyledInput.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,sBAAsB,EAAE,MAAM,OAAO,CAAC;AAG3D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,UAAU,gBAAiB,SAAQ,YAAY;IAC7C,IAAI,CAAC,EAAE,sBAAsB,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAMD,QAAA,MAAM,WAAW,+GA8GhB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -25,35 +25,24 @@ import { forwardRef } from 'react';
|
|
|
25
25
|
import { Controller } from 'react-hook-form';
|
|
26
26
|
import StyledVerticalStack from '../layout-helpers/StyledVerticalStack';
|
|
27
27
|
import StyledLoadingSpinner from '../StyledLoadingSpinner';
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return 'pl-7';
|
|
32
|
-
case 2:
|
|
33
|
-
return 'pl-9';
|
|
34
|
-
case 3:
|
|
35
|
-
return 'pl-12';
|
|
36
|
-
case 4:
|
|
37
|
-
return 'pl-15';
|
|
38
|
-
case 5:
|
|
39
|
-
return 'pl-16';
|
|
40
|
-
default:
|
|
41
|
-
return '';
|
|
42
|
-
}
|
|
28
|
+
function getMargin(affix) {
|
|
29
|
+
var _a;
|
|
30
|
+
return 12 + ((_a = affix === null || affix === void 0 ? void 0 : affix.length) !== null && _a !== void 0 ? _a : 0) * 14;
|
|
43
31
|
}
|
|
44
32
|
var StyledInput = forwardRef(function (_a, ref) {
|
|
45
|
-
var control = _a.control, name = _a.name, autocomplete = _a.autocomplete, label = _a.label, rules = _a.rules, _b = _a.disabled, disabled = _b === void 0 ? false : _b, error = _a.error, _c = _a.type, type = _c === void 0 ? 'text' : _c, placeholder = _a.placeholder, prefix = _a.prefix, _d = _a.forceError, forceError = _d === void 0 ? false : _d, forceErrorMessage = _a.forceErrorMessage, _e = _a.hideLabel, hideLabel = _e === void 0 ? false : _e, _f = _a.darkTheme, darkTheme = _f === void 0 ? false : _f, _g = _a.loading, loading = _g === void 0 ? false : _g, _h = _a.full, full = _h === void 0 ? false : _h, _j = _a.small, small = _j === void 0 ? false : _j, _k = _a.smallLabel, smallLabel = _k === void 0 ? false : _k, props = __rest(_a, ["control", "name", "autocomplete", "label", "rules", "disabled", "error", "type", "placeholder", "prefix", "forceError", "forceErrorMessage", "hideLabel", "darkTheme", "loading", "full", "small", "smallLabel"]);
|
|
33
|
+
var control = _a.control, name = _a.name, autocomplete = _a.autocomplete, label = _a.label, rules = _a.rules, _b = _a.disabled, disabled = _b === void 0 ? false : _b, error = _a.error, _c = _a.type, type = _c === void 0 ? 'text' : _c, placeholder = _a.placeholder, prefix = _a.prefix, buttonLabel = _a.buttonLabel, buttonClick = _a.buttonClick, _d = _a.forceError, forceError = _d === void 0 ? false : _d, forceErrorMessage = _a.forceErrorMessage, _e = _a.hideLabel, hideLabel = _e === void 0 ? false : _e, _f = _a.darkTheme, darkTheme = _f === void 0 ? false : _f, _g = _a.loading, loading = _g === void 0 ? false : _g, _h = _a.full, full = _h === void 0 ? false : _h, _j = _a.small, small = _j === void 0 ? false : _j, _k = _a.smallLabel, smallLabel = _k === void 0 ? false : _k, props = __rest(_a, ["control", "name", "autocomplete", "label", "rules", "disabled", "error", "type", "placeholder", "prefix", "buttonLabel", "buttonClick", "forceError", "forceErrorMessage", "hideLabel", "darkTheme", "loading", "full", "small", "smallLabel"]);
|
|
46
34
|
var textColor = darkTheme ? 'text-white' : 'text-dfxBlue-800';
|
|
47
35
|
var backgroundColor = darkTheme ? 'bg-white bg-opacity-5' : 'bg-white';
|
|
48
36
|
var placeholderColor = darkTheme ? 'placeholder:text-dfxGray-800' : 'placeholder:text-dfxGray-600';
|
|
49
37
|
var borderColor = darkTheme ? 'border-none' : 'border border-dfxGray-500';
|
|
50
38
|
var outlineColor = darkTheme ? 'outline-none' : 'outline-2 outline-dfxBlue-400';
|
|
51
|
-
var
|
|
52
|
-
var
|
|
39
|
+
var paddingLeft = getMargin(prefix);
|
|
40
|
+
var paddingRight = getMargin(buttonLabel);
|
|
41
|
+
var textOrErrorColor = error || forceError ? 'text-dfxRed-100' : textColor;
|
|
53
42
|
return (_jsx(Controller, { control: control, render: function (_a) {
|
|
54
43
|
var _b = _a.field, onChange = _b.onChange, onBlur = _b.onBlur, value = _b.value;
|
|
55
|
-
return (_jsxs(StyledVerticalStack, __assign({ gap: 1, full: full }, { children: [_jsx("label", __assign({ hidden: hideLabel, className: "text-start ".concat(smallLabel ? 'text-sm' : 'text-base', " font-semibold pl-3 pl- ") + [textColor].join(' ') }, { children: label })), _jsxs("div", __assign({ className: "relative" }, { children: [prefix && (_jsx("div", __assign({ className: "text-dfxGray-800 absolute
|
|
56
|
-
[textOrErrorColor, backgroundColor, placeholderColor, borderColor, outlineColor
|
|
44
|
+
return (_jsxs(StyledVerticalStack, __assign({ gap: 1, full: full }, { children: [label && (_jsx("label", __assign({ hidden: hideLabel, className: "text-start ".concat(smallLabel ? 'text-sm' : 'text-base', " font-semibold pl-3 pl- ") + [textColor].join(' ') }, { children: label }))), _jsxs("div", __assign({ className: "relative" }, { children: [prefix && (_jsx("div", __assign({ className: "text-dfxGray-800 absolute ".concat(prefix.length > 0 ? 'left-3' : '', " flex justify-center items-center"), style: { height: '3.5rem' } }, { children: _jsx("p", { children: prefix }) }))), loading && (_jsx("div", __assign({ className: "absolute right-3 h-w-8 flex justify-center items-center", style: { height: '3.5rem' } }, { children: _jsx(StyledLoadingSpinner, {}) }))), buttonLabel && !loading && (_jsx("div", __assign({ className: "text-dfxRed-100 absolute ".concat(buttonLabel.length > 0 ? 'right-3' : '', " flex justify-center items-center"), style: { height: '3.5rem' } }, { children: _jsx("button", __assign({ onClick: buttonClick }, { children: buttonLabel })) }))), _jsx("input", __assign({ className: "text-base font-normal rounded-md p-4 ".concat(small ? 'w-24' : 'w-full', " ") +
|
|
45
|
+
[textOrErrorColor, backgroundColor, placeholderColor, borderColor, outlineColor].join(' '), style: { paddingLeft: paddingLeft, paddingRight: paddingRight }, type: type, name: autocomplete !== null && autocomplete !== void 0 ? autocomplete : name, inputMode: type === 'number' ? 'decimal' : undefined, onBlur: onBlur, onChange: function (value) { return onChange(value.target.value); }, placeholder: placeholder, value: value !== null && value !== void 0 ? value : '', disabled: disabled, ref: ref, onWheel: function (e) { return type === 'number' && e.currentTarget.blur(); } }, props))] })), (forceErrorMessage || error) && (_jsx("p", __assign({ className: "text-start text-sm text-dfxRed-100 pl-3" }, { children: forceErrorMessage !== null && forceErrorMessage !== void 0 ? forceErrorMessage : error === null || error === void 0 ? void 0 : error.message })))] })));
|
|
57
46
|
}, name: name, rules: rules }));
|
|
58
47
|
});
|
|
59
48
|
export default StyledInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StyledInput.js","sourceRoot":"","sources":["../../../src/stories/form/StyledInput.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,mBAAmB,MAAM,uCAAuC,CAAC;AAExE,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"StyledInput.js","sourceRoot":"","sources":["../../../src/stories/form/StyledInput.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAA0B,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,mBAAmB,MAAM,uCAAuC,CAAC;AAExE,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAmB3D,SAA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E,KAAK,GACZ,CACH,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,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,MAA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,CACb,8BACE,cACE,SAAS,EAAE,iCACT,KAAK,CAAC,KAAK,KAAK,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,UACrD,GACP,EACD,KAAK,CAAC,IAAI,CAAC,UAAC,IAAI;wCACf,QAAQ,CAAC,IAAI,CAAC,CAAC;wCACf,YAAY,CAAC,KAAK,CAAC,CAAC;oCACtB,CAAC,CAAC,IACD,CACJ,KACW,EACd,KAAC,iBAAiB,aAChB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,cAAM,OAAA,YAAY,CAAC,IAAI,CAAC,EAAlB,CAAkB,EACjC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,IAAI,SAAS,CAAC,KAAK,CAAC,EAChC,WAAW,EAAE,KAAK,KAAI,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAG,KAAK,CAAC,CAAA,IAC1C,KAAK,EACT,IACD,CACJ;QAlDmD,CAkDnD,EACD,IAAI,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.21",
|
|
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": "e7e4e294ea55ed611773874a2a9ffdd889a58f59"
|
|
91
91
|
}
|