@nobak/design-system 1.0.0
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/LICENSE +73 -0
- package/README.md +142 -0
- package/lib/assets/icons.js +67 -0
- package/lib/components/AccountOverview/AccountOverview.js +122 -0
- package/lib/components/AdminPanel.js +58 -0
- package/lib/components/AssetExchange/AssetExchange.js +189 -0
- package/lib/components/AuthenticationFlow.js +216 -0
- package/lib/components/ConversationInterface/ConversationInterface.js +232 -0
- package/lib/components/DevFooter.js +38 -0
- package/lib/components/DevMenu.js +35 -0
- package/lib/components/DevSidebar.js +28 -0
- package/lib/components/DigitalDisplay.js +83 -0
- package/lib/components/Footer.js +45 -0
- package/lib/components/HeroContainer.js +10 -0
- package/lib/components/IntentRecognition/IntentRecognition.js +174 -0
- package/lib/components/Logo.js +259 -0
- package/lib/components/MenuBar.js +56 -0
- package/lib/components/NetworkSettings.js +223 -0
- package/lib/components/RecoverySetup/RecoverySetup.js +354 -0
- package/lib/components/RisingSun.js +122 -0
- package/lib/components/Symbol.js +226 -0
- package/lib/components/TransactionComposer/TransactionComposer.js +258 -0
- package/lib/components/TransactionConfirmation.js +184 -0
- package/lib/components/WalletMenu.js +33 -0
- package/lib/components/console/code/CodeBlock.js +150 -0
- package/lib/components/console/code/index.js +9 -0
- package/lib/components/console/data/DataTable.js +245 -0
- package/lib/components/console/data/MetricCard.js +79 -0
- package/lib/components/console/data/index.js +11 -0
- package/lib/components/console/documentation/index.js +10 -0
- package/lib/components/console/forms/APIKeyGenerator.js +261 -0
- package/lib/components/console/forms/SearchBar.js +210 -0
- package/lib/components/console/forms/index.js +10 -0
- package/lib/components/console/index.js +29 -0
- package/lib/components/console/layout/ConsoleCard.js +82 -0
- package/lib/components/console/layout/ConsoleLayout.js +86 -0
- package/lib/components/console/layout/index.js +10 -0
- package/lib/components/console/monitoring/StatusIndicator.js +128 -0
- package/lib/components/console/monitoring/index.js +9 -0
- package/lib/components/console/navigation/DevFooter.js +38 -0
- package/lib/components/console/navigation/DevMenu.js +35 -0
- package/lib/components/console/navigation/DevSidebar.js +28 -0
- package/lib/components/console/navigation/index.js +11 -0
- package/lib/components/console/settings/index.js +10 -0
- package/lib/components/index.js +12 -0
- package/lib/design/ColorPicker.stories.js +9 -0
- package/lib/design/HSLTool-V1.js +345 -0
- package/lib/design/HSLTool-V2.js +475 -0
- package/lib/design/HSLTool-V3.js +543 -0
- package/lib/design/HSLTool-V4.js +1139 -0
- package/lib/design/HSLTool.js +374 -0
- package/lib/design/OKLCHColorPicker.stories.js +24 -0
- package/lib/design/OKLCHTool.js +1014 -0
- package/lib/index.js +4 -0
- package/lib/shared/components/Avatar/Avatar.js +18 -0
- package/lib/shared/components/Avatar/index.js +1 -0
- package/lib/shared/components/Badge/Badge.js +34 -0
- package/lib/shared/components/Badge/index.js +1 -0
- package/lib/shared/components/Breadcrumb/Breadcrumb.js +13 -0
- package/lib/shared/components/Breadcrumb/index.js +1 -0
- package/lib/shared/components/Button/Button.js +184 -0
- package/lib/shared/components/Button/index.js +1 -0
- package/lib/shared/components/Calendar/Calendar.js +155 -0
- package/lib/shared/components/Calendar/CalendarDay.js +251 -0
- package/lib/shared/components/Calendar/CalendarHeader.js +88 -0
- package/lib/shared/components/Calendar/CalendarMonth.js +106 -0
- package/lib/shared/components/Calendar/CalendarWeek.js +267 -0
- package/lib/shared/components/Calendar/constants.js +73 -0
- package/lib/shared/components/Calendar/index.js +3 -0
- package/lib/shared/components/Calendar/types.d.js +0 -0
- package/lib/shared/components/Cartel/Cartel.js +44 -0
- package/lib/shared/components/Cartel/index.js +1 -0
- package/lib/shared/components/Cell/Cell.js +105 -0
- package/lib/shared/components/Cell/index.js +1 -0
- package/lib/shared/components/Checkbox/Checkbox.js +27 -0
- package/lib/shared/components/Checkbox/index.js +1 -0
- package/lib/shared/components/Clock/Clock.js +6 -0
- package/lib/shared/components/Clock/index.js +1 -0
- package/lib/shared/components/ColorChecker/ColorChecker.js +89 -0
- package/lib/shared/components/ColorChecker/index.js +2 -0
- package/lib/shared/components/ColorChecker/utils.js +159 -0
- package/lib/shared/components/Command/Command.js +95 -0
- package/lib/shared/components/Command/index.js +1 -0
- package/lib/shared/components/Container/Container.js +18 -0
- package/lib/shared/components/Container/index.js +1 -0
- package/lib/shared/components/Cover/Cover.js +17 -0
- package/lib/shared/components/Cover/index.js +1 -0
- package/lib/shared/components/DatePicker/DatePicker.js +52 -0
- package/lib/shared/components/DatePicker/components/Calendar.js +125 -0
- package/lib/shared/components/DatePicker/components/CalendarDay.js +23 -0
- package/lib/shared/components/DatePicker/components/DateWrapper.js +15 -0
- package/lib/shared/components/DatePicker/components/index.js +2 -0
- package/lib/shared/components/DatePicker/index.js +1 -0
- package/lib/shared/components/DateTime/DateTime.js +51 -0
- package/lib/shared/components/DateTime/index.js +1 -0
- package/lib/shared/components/Debug/Debug.js +12 -0
- package/lib/shared/components/Debug/index.js +1 -0
- package/lib/shared/components/Disclosure/Disclosure.js +31 -0
- package/lib/shared/components/Disclosure/index.js +1 -0
- package/lib/shared/components/Dropdown/Dropdown.js +91 -0
- package/lib/shared/components/Dropdown/index.js +1 -0
- package/lib/shared/components/EmptyState/EmptyState.js +40 -0
- package/lib/shared/components/EmptyState/index.js +1 -0
- package/lib/shared/components/Form/Form.js +41 -0
- package/lib/shared/components/Form/components/DynamicForm.js +66 -0
- package/lib/shared/components/Form/components/StepperForm.js +266 -0
- package/lib/shared/components/Form/components/index.js +2 -0
- package/lib/shared/components/Form/context/Form.js +164 -0
- package/lib/shared/components/Form/context/index.js +1 -0
- package/lib/shared/components/Form/index.js +1 -0
- package/lib/shared/components/Form/types.d.js +1 -0
- package/lib/shared/components/Form/utils/index.js +31 -0
- package/lib/shared/components/GroupItems/GroupItems.js +17 -0
- package/lib/shared/components/GroupItems/index.js +1 -0
- package/lib/shared/components/Header/Header.js +26 -0
- package/lib/shared/components/Header/index.js +1 -0
- package/lib/shared/components/Heading/Heading.js +5 -0
- package/lib/shared/components/Heading/index.js +1 -0
- package/lib/shared/components/Icon/Icon.js +28 -0
- package/lib/shared/components/Icon/index.js +1 -0
- package/lib/shared/components/Identicons/Identicons.js +6 -0
- package/lib/shared/components/Identicons/index.d.js +0 -0
- package/lib/shared/components/Identicons/index.js +1 -0
- package/lib/shared/components/Image/Image.js +22 -0
- package/lib/shared/components/Image/index.js +1 -0
- package/lib/shared/components/Input/Input.js +201 -0
- package/lib/shared/components/Input/components/CheckBoxInput.js +81 -0
- package/lib/shared/components/Input/components/DateInput.js +89 -0
- package/lib/shared/components/Input/components/DefaultInput.js +102 -0
- package/lib/shared/components/Input/components/FileReaderInput.js +88 -0
- package/lib/shared/components/Input/components/NumberInput.js +141 -0
- package/lib/shared/components/Input/components/PickerInput.js +122 -0
- package/lib/shared/components/Input/components/RCInput.js +112 -0
- package/lib/shared/components/Input/components/Radiobox/RadioboxBasic.js +56 -0
- package/lib/shared/components/Input/components/Radiobox/RadioboxCard.js +27 -0
- package/lib/shared/components/Input/components/Radiobox/RadioboxFull.js +44 -0
- package/lib/shared/components/Input/components/Radiobox/index.js +3 -0
- package/lib/shared/components/Input/components/RadioboxInput.js +102 -0
- package/lib/shared/components/Input/components/SelectInput.js +70 -0
- package/lib/shared/components/Input/components/TextAreaInput.js +67 -0
- package/lib/shared/components/Input/components/TextInput.js +139 -0
- package/lib/shared/components/Input/components/TimeInput.js +37 -0
- package/lib/shared/components/Input/components/UploadFileInput.js +123 -0
- package/lib/shared/components/Input/components/index.js +13 -0
- package/lib/shared/components/Input/components/types.d.js +0 -0
- package/lib/shared/components/Input/index.js +1 -0
- package/lib/shared/components/Input/types.d.js +0 -0
- package/lib/shared/components/Layout/Layout.js +13 -0
- package/lib/shared/components/Layout/index.js +1 -0
- package/lib/shared/components/List/List.js +30 -0
- package/lib/shared/components/List/index.js +1 -0
- package/lib/shared/components/Loader/Loader.js +27 -0
- package/lib/shared/components/Loader/index.js +1 -0
- package/lib/shared/components/Modal/Modal.js +102 -0
- package/lib/shared/components/Modal/index.js +1 -0
- package/lib/shared/components/Notification/Notification.js +39 -0
- package/lib/shared/components/Notification/index.js +1 -0
- package/lib/shared/components/Person/Person.js +81 -0
- package/lib/shared/components/Person/index.js +1 -0
- package/lib/shared/components/Popover/Popover.js +39 -0
- package/lib/shared/components/Popover/index.js +1 -0
- package/lib/shared/components/QRCode/QRCode.js +329 -0
- package/lib/shared/components/QRCode/index.js +1 -0
- package/lib/shared/components/RadioGroup/RadioGroup.js +35 -0
- package/lib/shared/components/RadioGroup/components/DefaultGroup.js +71 -0
- package/lib/shared/components/RadioGroup/components/VerticalGroup.js +83 -0
- package/lib/shared/components/RadioGroup/components/index.js +2 -0
- package/lib/shared/components/RadioGroup/index.js +1 -0
- package/lib/shared/components/Search/Search.js +12 -0
- package/lib/shared/components/Search/index.js +1 -0
- package/lib/shared/components/Select/Select.js +90 -0
- package/lib/shared/components/Select/index.js +1 -0
- package/lib/shared/components/Sidebar/Sidebar.js +42 -0
- package/lib/shared/components/Sidebar/index.js +1 -0
- package/lib/shared/components/SlideOver/SlideOver.js +81 -0
- package/lib/shared/components/SlideOver/index.js +1 -0
- package/lib/shared/components/Slider/Slider.js +80 -0
- package/lib/shared/components/Slider/index.js +1 -0
- package/lib/shared/components/Stepper/Stepper.js +32 -0
- package/lib/shared/components/Stepper/index.js +1 -0
- package/lib/shared/components/Steps/Steps.js +53 -0
- package/lib/shared/components/Steps/index.js +1 -0
- package/lib/shared/components/Switch/Switch.js +26 -0
- package/lib/shared/components/Switch/index.js +1 -0
- package/lib/shared/components/Tab/Tab.js +59 -0
- package/lib/shared/components/Tab/index.js +1 -0
- package/lib/shared/components/Table/Table.js +47 -0
- package/lib/shared/components/Table/index.js +1 -0
- package/lib/shared/components/Text/Text.js +11 -0
- package/lib/shared/components/Text/index.js +1 -0
- package/lib/shared/components/TextList/TextList.js +15 -0
- package/lib/shared/components/TextList/index.js +1 -0
- package/lib/shared/components/TimePicker/TimePicker.js +161 -0
- package/lib/shared/components/TimePicker/index.js +1 -0
- package/lib/shared/components/Tooltip/Tooltip.js +13 -0
- package/lib/shared/components/Tooltip/index.js +1 -0
- package/lib/shared/components/Uploader/Uploader.js +63 -0
- package/lib/shared/components/Uploader/index.js +1 -0
- package/lib/shared/components/Video/Video.js +20 -0
- package/lib/shared/components/Video/index.js +1 -0
- package/lib/shared/components/index.d.js +0 -0
- package/lib/shared/components/index.js +50 -0
- package/lib/shared/elements/Color/ColorPallet.js +20 -0
- package/lib/shared/elements/Color/index.js +1 -0
- package/lib/shared/elements/Text.js +37 -0
- package/lib/shared/elements/index.js +1 -0
- package/lib/shared/helpers/FakeLink.js +8 -0
- package/lib/shared/helpers/constants.js +359 -0
- package/lib/shared/helpers/index.js +2 -0
- package/lib/shared/helpers/isEqual.js +56 -0
- package/lib/shared/index.d.js +0 -0
- package/lib/shared/index.js +1 -0
- package/lib/shared/stories/components/Avatar.stories.js +17 -0
- package/lib/shared/stories/components/Badge.stories.dev.js +37 -0
- package/lib/shared/stories/components/Button.stories.js +553 -0
- package/lib/shared/stories/components/Calendar.stories.js +62 -0
- package/lib/shared/stories/components/Cartel.stories.js +32 -0
- package/lib/shared/stories/components/Checkbox.stories.js +15 -0
- package/lib/shared/stories/components/ColorChecker.stories.dev.js +16 -0
- package/lib/shared/stories/components/DateTime.stories.js +27 -0
- package/lib/shared/stories/components/Disclosure.stories.js +30 -0
- package/lib/shared/stories/components/Dropdown.stories.js +39 -0
- package/lib/shared/stories/components/Form/Default.stories.js +201 -0
- package/lib/shared/stories/components/Form/DummyForm.stories.js +48 -0
- package/lib/shared/stories/components/Form/DynamicForm.stories.js +155 -0
- package/lib/shared/stories/components/Form/StepperForm.stories.js +138 -0
- package/lib/shared/stories/components/Form/ValidateForm.stories.js +70 -0
- package/lib/shared/stories/components/Form/Validation.stories.js +184 -0
- package/lib/shared/stories/components/GroupItems.stories.js +23 -0
- package/lib/shared/stories/components/Header.stories.js +29 -0
- package/lib/shared/stories/components/Heading.stories.js +27 -0
- package/lib/shared/stories/components/Icon.stories.js +22 -0
- package/lib/shared/stories/components/Image.stories.js +23 -0
- package/lib/shared/stories/components/Input/Checkbox.stories.js +45 -0
- package/lib/shared/stories/components/Input/DatePicker.stories.js +23 -0
- package/lib/shared/stories/components/Input/Defaut.stories.js +24 -0
- package/lib/shared/stories/components/Input/Number.stories.js +24 -0
- package/lib/shared/stories/components/Input/RCI.stories.js +59 -0
- package/lib/shared/stories/components/Input/Radiobox.stories.dev.js +28 -0
- package/lib/shared/stories/components/Input/Select.stories.dev.js +27 -0
- package/lib/shared/stories/components/Input/SelectMultiple.stories.dev.js +510 -0
- package/lib/shared/stories/components/Input/Textarea.stories.js +24 -0
- package/lib/shared/stories/components/List.stories.js +34 -0
- package/lib/shared/stories/components/Loader.stories.js +15 -0
- package/lib/shared/stories/components/Modal.stories.js +50 -0
- package/lib/shared/stories/components/Notification.stories.js +22 -0
- package/lib/shared/stories/components/Person.stories.js +41 -0
- package/lib/shared/stories/components/Picker.stories.js +15 -0
- package/lib/shared/stories/components/Popover.stories.js +36 -0
- package/lib/shared/stories/components/QRCode.stories.js +20 -0
- package/lib/shared/stories/components/RadioGroup.stories.js +56 -0
- package/lib/shared/stories/components/Select.stories.js +50 -0
- package/lib/shared/stories/components/Sidebar.stories.js +35 -0
- package/lib/shared/stories/components/Slider.stories.dev.js +48 -0
- package/lib/shared/stories/components/Stepper/Stepper.stories.js +38 -0
- package/lib/shared/stories/components/Steps.stories.js +15 -0
- package/lib/shared/stories/components/Switch.stories.js +15 -0
- package/lib/shared/stories/components/Tab.stories.js +15 -0
- package/lib/shared/stories/components/Table.stories.js +95 -0
- package/lib/shared/stories/components/TextList.stories.js +23 -0
- package/lib/shared/stories/components/Tooltip.stories.dev.js +40 -0
- package/lib/shared/stories/elements/Color.stories.js +269 -0
- package/lib/shared/stories/elements/Text.stories.js +45 -0
- package/lib/shared/types/index.js +1 -0
- package/lib/stories/Foundation/BrandIdentity.prod.stories.js +510 -0
- package/lib/stories/Foundation/Logo.stories.js +19 -0
- package/lib/stories/Foundation/RisingSun.stories.js +16 -0
- package/lib/stories/Foundation/Shadows.stories.js +601 -0
- package/lib/stories/Foundation/Symbol.stories.js +18 -0
- package/lib/stories/HeroContainer.stories.js +18 -0
- package/lib/styles/accessibilityTokens.js +72 -0
- package/lib/styles/borderWidth.js +10 -0
- package/lib/styles/colors.js +303 -0
- package/lib/styles/elevation.js +240 -0
- package/lib/styles/icons.js +218 -0
- package/lib/styles/index.js +29 -0
- package/lib/styles/motion.js +668 -0
- package/lib/styles/opacity.js +10 -0
- package/lib/styles/radius.js +11 -0
- package/lib/styles/sizing.js +35 -0
- package/lib/styles/space.js +24 -0
- package/lib/styles/theme/darkTheme.js +471 -0
- package/lib/styles/theme/index.js +44 -0
- package/lib/styles/theme/lightTheme.js +480 -0
- package/lib/styles/theme/themeTypes.js +1 -0
- package/lib/styles/theme/themeUtils.js +63 -0
- package/lib/styles/typography-advanced.js +510 -0
- package/lib/styles/typography.js +1419 -0
- package/lib/styles/zIndex.js +19 -0
- package/lib/tokens/borders.js +161 -0
- package/lib/tokens/colors.js +426 -0
- package/lib/tokens/components.js +499 -0
- package/lib/tokens/index.js +84 -0
- package/lib/tokens/lighting.js +384 -0
- package/lib/tokens/motion.js +284 -0
- package/lib/tokens/semantic.js +367 -0
- package/lib/tokens/shadows.js +114 -0
- package/lib/tokens/spacing.js +189 -0
- package/lib/tokens/typography.js +268 -0
- package/package.json +176 -0
- package/styles/generated-tokens.css +677 -0
- package/styles/index.css +2 -0
- package/styles/main.css +610 -0
- package/tailwind.config.js +64 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
import React, { useState } from 'react';
|
|
8
|
+
import { Button } from "../../shared/elements/Button/Button";
|
|
9
|
+
import { Text } from "../../shared/elements/Text/Text";
|
|
10
|
+
import { Badge } from "../../shared/elements/Badge/Badge";
|
|
11
|
+
import { Loader } from "../../shared/elements/Loader/Loader";
|
|
12
|
+
import { Icon } from "../../shared/elements/Icon/Icon";
|
|
13
|
+
|
|
14
|
+
// Types for assets and props
|
|
15
|
+
|
|
16
|
+
var securityColors = {
|
|
17
|
+
low: 'bg-alert-400 text-alert-900',
|
|
18
|
+
medium: 'bg-warning-200 text-warning-900',
|
|
19
|
+
high: 'bg-positive-200 text-positive-900'
|
|
20
|
+
};
|
|
21
|
+
var securityLabels = {
|
|
22
|
+
low: 'Low',
|
|
23
|
+
medium: 'Medium',
|
|
24
|
+
high: 'High'
|
|
25
|
+
};
|
|
26
|
+
export var AccountOverview = function AccountOverview(_ref) {
|
|
27
|
+
var publicKey = _ref.publicKey,
|
|
28
|
+
balances = _ref.balances,
|
|
29
|
+
isVerified = _ref.isVerified,
|
|
30
|
+
securityLevel = _ref.securityLevel,
|
|
31
|
+
_ref$loading = _ref.loading,
|
|
32
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
33
|
+
onSend = _ref.onSend,
|
|
34
|
+
onReceive = _ref.onReceive,
|
|
35
|
+
onConvert = _ref.onConvert;
|
|
36
|
+
var _useState = useState(false),
|
|
37
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
38
|
+
copied = _useState2[0],
|
|
39
|
+
setCopied = _useState2[1];
|
|
40
|
+
var handleCopy = function handleCopy() {
|
|
41
|
+
navigator.clipboard.writeText(publicKey);
|
|
42
|
+
setCopied(true);
|
|
43
|
+
setTimeout(function () {
|
|
44
|
+
return setCopied(false);
|
|
45
|
+
}, 1500);
|
|
46
|
+
};
|
|
47
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: "w-full max-w-xl mx-auto"
|
|
49
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
50
|
+
className: "bg-white rounded-xl shadow-md p-6 flex flex-col gap-4"
|
|
51
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
52
|
+
className: "flex flex-col md:flex-row md:items-center gap-2 justify-between"
|
|
53
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
54
|
+
content: "Public Key",
|
|
55
|
+
fontSize: ": "
|
|
56
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
57
|
+
className: "flex items-center gap-2"
|
|
58
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
59
|
+
content: "".concat(publicKey.slice(0, 6), "...").concat(publicKey.slice(-6)),
|
|
60
|
+
fontSize: ": "
|
|
61
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
62
|
+
variant: "basic",
|
|
63
|
+
size: "tiny",
|
|
64
|
+
icon: "copy",
|
|
65
|
+
text: copied ? 'Copied!' : 'Copy',
|
|
66
|
+
onClick: handleCopy
|
|
67
|
+
}))), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Text, {
|
|
68
|
+
content: "Balances",
|
|
69
|
+
fontSize: ": "
|
|
70
|
+
}), loading ? /*#__PURE__*/React.createElement("div", {
|
|
71
|
+
className: "flex items-center justify-center py-4"
|
|
72
|
+
}, /*#__PURE__*/React.createElement(Loader, null)) : /*#__PURE__*/React.createElement("div", {
|
|
73
|
+
className: "flex flex-wrap gap-3 mt-2"
|
|
74
|
+
}, balances.map(function (asset, idx) {
|
|
75
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
76
|
+
key: asset.asset_code + idx,
|
|
77
|
+
className: "flex flex-col items-start bg-neutral-100 rounded-lg px-3 py-2 min-w-[110px]"
|
|
78
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
79
|
+
className: "font-mono text-neutral-800 text-[16px]"
|
|
80
|
+
}, asset.balance), /*#__PURE__*/React.createElement(Badge, {
|
|
81
|
+
title: asset.asset_code,
|
|
82
|
+
variant: "primary",
|
|
83
|
+
size: "small"
|
|
84
|
+
}));
|
|
85
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
86
|
+
className: "flex flex-wrap gap-3 mt-2"
|
|
87
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
88
|
+
variant: "primary",
|
|
89
|
+
text: "Send",
|
|
90
|
+
icon: "arrow-up",
|
|
91
|
+
onClick: onSend
|
|
92
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
93
|
+
variant: "secondary",
|
|
94
|
+
text: "Receive",
|
|
95
|
+
icon: "arrow-down",
|
|
96
|
+
onClick: onReceive
|
|
97
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
98
|
+
variant: "outline",
|
|
99
|
+
text: "Convert",
|
|
100
|
+
icon: "swap",
|
|
101
|
+
onClick: onConvert
|
|
102
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
103
|
+
className: "flex flex-wrap gap-3 items-center mt-2"
|
|
104
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
105
|
+
className: "flex items-center gap-2"
|
|
106
|
+
}, /*#__PURE__*/React.createElement(Badge, {
|
|
107
|
+
title: isVerified ? 'Verified' : 'Unverified',
|
|
108
|
+
variant: isVerified ? 'positive' : 'warning',
|
|
109
|
+
size: "small"
|
|
110
|
+
}), /*#__PURE__*/React.createElement(Text, {
|
|
111
|
+
content: "Account Status",
|
|
112
|
+
fontSize: ": "
|
|
113
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
114
|
+
className: "flex items-center gap-2 px-2 py-1 rounded-lg ".concat(securityColors[securityLevel])
|
|
115
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
116
|
+
name: "shield",
|
|
117
|
+
size: 16
|
|
118
|
+
}), /*#__PURE__*/React.createElement(Text, {
|
|
119
|
+
content: "Security: ".concat(securityLabels[securityLevel]),
|
|
120
|
+
fontSize: ": "
|
|
121
|
+
})))));
|
|
122
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button } from "../shared";
|
|
3
|
+
var AdminPanel = function AdminPanel(_ref) {
|
|
4
|
+
var children = _ref.children,
|
|
5
|
+
Link = _ref.component,
|
|
6
|
+
toStatus = _ref.toStatus,
|
|
7
|
+
toCredentials = _ref.toCredentials,
|
|
8
|
+
toProfile = _ref.toProfile;
|
|
9
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
10
|
+
className: "flex flex-col md:flex-row bg-primary-400 rounded-xl shadow-lg border-primary-700 border"
|
|
11
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
12
|
+
className: "flex flex-col space-y-6 border-r border-primary-1200 md:w-64 w-full"
|
|
13
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
14
|
+
className: "pl-4 pr-4 pt-4 border-b border-primary-900"
|
|
15
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
16
|
+
className: "pl-4 pr-4 pt-2 border-b border-primary-900"
|
|
17
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
className: "text-p2-light"
|
|
19
|
+
}, "Servers")), /*#__PURE__*/React.createElement("div", {
|
|
20
|
+
className: "flex flex-col space-y-2 pl-2 pr-2 pt-2"
|
|
21
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
22
|
+
text: "Network",
|
|
23
|
+
variant: "basic",
|
|
24
|
+
size: "small",
|
|
25
|
+
type: "link",
|
|
26
|
+
component: Link,
|
|
27
|
+
to: toStatus
|
|
28
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
className: "pl-4 pr-4 pt-2 border-b border-primary-900"
|
|
30
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
31
|
+
className: "text-p2-light"
|
|
32
|
+
}, "Security")), /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
className: "flex flex-col space-y-2 pl-2 pr-2 pt-2"
|
|
34
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
35
|
+
text: "Credentials",
|
|
36
|
+
variant: "basic",
|
|
37
|
+
size: "small",
|
|
38
|
+
type: "link",
|
|
39
|
+
component: Link,
|
|
40
|
+
to: toCredentials
|
|
41
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
42
|
+
className: "pl-4 pr-4 pt-2 border-b border-primary-900"
|
|
43
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
44
|
+
className: "text-p2-light"
|
|
45
|
+
}, "Settings")), /*#__PURE__*/React.createElement("div", {
|
|
46
|
+
className: "flex flex-col space-y-2 pl-2 pr-2 pt-2"
|
|
47
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
48
|
+
text: "Profile",
|
|
49
|
+
variant: "basic",
|
|
50
|
+
size: "small",
|
|
51
|
+
type: "link",
|
|
52
|
+
component: Link,
|
|
53
|
+
to: toProfile
|
|
54
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
55
|
+
className: "flex flex-1 p-4 h-auto items-center justify-center md:h-[600px]"
|
|
56
|
+
}, children));
|
|
57
|
+
};
|
|
58
|
+
export { AdminPanel };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
import React, { useState, useEffect } from 'react';
|
|
8
|
+
import { Form } from "../../shared/components/forms/Form/Form";
|
|
9
|
+
import { Button } from "../../shared/elements/Button/Button";
|
|
10
|
+
// Placeholder for ExchangeRateCard
|
|
11
|
+
var ExchangeRateCard = function ExchangeRateCard(_ref) {
|
|
12
|
+
var rate = _ref.rate,
|
|
13
|
+
loading = _ref.loading;
|
|
14
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
15
|
+
className: "bg-neutral-50 border p-3 rounded mb-3 flex items-center justify-between"
|
|
16
|
+
}, loading ? /*#__PURE__*/React.createElement("span", {
|
|
17
|
+
className: "text-neutral-400"
|
|
18
|
+
}, "Loading rate...") : /*#__PURE__*/React.createElement("span", null, "Exchange Rate: ", /*#__PURE__*/React.createElement("b", null, rate)));
|
|
19
|
+
};
|
|
20
|
+
var EXAMPLE_ASSETS = [{
|
|
21
|
+
code: 'XLM',
|
|
22
|
+
issuer: '',
|
|
23
|
+
balance: '1000'
|
|
24
|
+
}, {
|
|
25
|
+
code: 'USDC',
|
|
26
|
+
issuer: 'GA...USDC',
|
|
27
|
+
balance: '250'
|
|
28
|
+
}, {
|
|
29
|
+
code: 'BTC',
|
|
30
|
+
issuer: 'GA...BTC',
|
|
31
|
+
balance: '0.05'
|
|
32
|
+
}];
|
|
33
|
+
export var AssetExchange = function AssetExchange() {
|
|
34
|
+
var _useState = useState(EXAMPLE_ASSETS[0].code),
|
|
35
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
36
|
+
sourceAsset = _useState2[0],
|
|
37
|
+
setSourceAsset = _useState2[1];
|
|
38
|
+
var _useState3 = useState(EXAMPLE_ASSETS[1].code),
|
|
39
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
40
|
+
destAsset = _useState4[0],
|
|
41
|
+
setDestAsset = _useState4[1];
|
|
42
|
+
var _useState5 = useState(''),
|
|
43
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
44
|
+
amount = _useState6[0],
|
|
45
|
+
setAmount = _useState6[1];
|
|
46
|
+
var _useState7 = useState(''),
|
|
47
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
48
|
+
converted = _useState8[0],
|
|
49
|
+
setConverted = _useState8[1];
|
|
50
|
+
var _useState9 = useState(''),
|
|
51
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
52
|
+
rate = _useState0[0],
|
|
53
|
+
setRate = _useState0[1];
|
|
54
|
+
var _useState1 = useState(false),
|
|
55
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
56
|
+
loadingRate = _useState10[0],
|
|
57
|
+
setLoadingRate = _useState10[1];
|
|
58
|
+
var _useState11 = useState('0.5'),
|
|
59
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
60
|
+
slippage = _useState12[0],
|
|
61
|
+
setSlippage = _useState12[1];
|
|
62
|
+
var _useState13 = useState('0.00001'),
|
|
63
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
64
|
+
fee = _useState14[0],
|
|
65
|
+
setFee = _useState14[1];
|
|
66
|
+
var _useState15 = useState(''),
|
|
67
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
68
|
+
impact = _useState16[0],
|
|
69
|
+
setImpact = _useState16[1];
|
|
70
|
+
var _useState17 = useState(null),
|
|
71
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
72
|
+
preview = _useState18[0],
|
|
73
|
+
setPreview = _useState18[1];
|
|
74
|
+
|
|
75
|
+
// Simulate fetching exchange rate
|
|
76
|
+
useEffect(function () {
|
|
77
|
+
if (sourceAsset === destAsset) {
|
|
78
|
+
setRate('1.00');
|
|
79
|
+
setConverted(amount);
|
|
80
|
+
setImpact('0');
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
setLoadingRate(true);
|
|
84
|
+
setTimeout(function () {
|
|
85
|
+
// Fake rates for demo
|
|
86
|
+
var fakeRate = sourceAsset === 'XLM' && destAsset === 'USDC' ? 0.99 : 0.00002;
|
|
87
|
+
setRate(fakeRate.toString());
|
|
88
|
+
setConverted(amount ? (parseFloat(amount) * fakeRate).toFixed(6) : '');
|
|
89
|
+
setImpact((parseFloat(slippage) * 0.01).toFixed(4));
|
|
90
|
+
setLoadingRate(false);
|
|
91
|
+
}, 600);
|
|
92
|
+
}, [sourceAsset, destAsset, amount, slippage]);
|
|
93
|
+
|
|
94
|
+
// Simulate fee estimation
|
|
95
|
+
useEffect(function () {
|
|
96
|
+
setFee('0.00001');
|
|
97
|
+
}, [amount, sourceAsset, destAsset]);
|
|
98
|
+
var handlePreview = function handlePreview() {
|
|
99
|
+
if (!amount || !converted || !rate) return;
|
|
100
|
+
setPreview({
|
|
101
|
+
sourceAsset: sourceAsset,
|
|
102
|
+
destAsset: destAsset,
|
|
103
|
+
amount: amount,
|
|
104
|
+
converted: converted,
|
|
105
|
+
rate: rate,
|
|
106
|
+
slippage: slippage,
|
|
107
|
+
fee: fee,
|
|
108
|
+
impact: impact
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
112
|
+
className: "w-full max-w-lg mx-auto bg-white rounded-xl shadow-md p-6 mt-4 flex flex-col gap-6"
|
|
113
|
+
}, /*#__PURE__*/React.createElement(Form, {
|
|
114
|
+
fields: [{
|
|
115
|
+
field: {
|
|
116
|
+
type: 'select',
|
|
117
|
+
label: 'From',
|
|
118
|
+
value: sourceAsset,
|
|
119
|
+
onChange: function onChange(e) {
|
|
120
|
+
return setSourceAsset(e.target.value);
|
|
121
|
+
},
|
|
122
|
+
options: EXAMPLE_ASSETS.map(function (a) {
|
|
123
|
+
return {
|
|
124
|
+
label: "".concat(a.code).concat(a.issuer ? ': ' + a.issuer.slice(0, 6) + '...)' : ''),
|
|
125
|
+
value: a.code
|
|
126
|
+
};
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
}, {
|
|
130
|
+
field: {
|
|
131
|
+
type: 'select',
|
|
132
|
+
label: ': ',
|
|
133
|
+
value: destAsset,
|
|
134
|
+
onChange: function onChange(e) {
|
|
135
|
+
return setDestAsset(e.target.value);
|
|
136
|
+
},
|
|
137
|
+
options: EXAMPLE_ASSETS.map(function (a) {
|
|
138
|
+
return {
|
|
139
|
+
label: "".concat(a.code).concat(a.issuer ? ', ' + a.issuer.slice(0, 6) + '...)' : ''),
|
|
140
|
+
value: a.code
|
|
141
|
+
};
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
}, {
|
|
145
|
+
field: {
|
|
146
|
+
type: 'text',
|
|
147
|
+
label: 'Amount',
|
|
148
|
+
value: amount,
|
|
149
|
+
onChange: function onChange(e) {
|
|
150
|
+
return setAmount(e.target.value);
|
|
151
|
+
},
|
|
152
|
+
placeholder: '0.00'
|
|
153
|
+
}
|
|
154
|
+
}, {
|
|
155
|
+
field: {
|
|
156
|
+
type: 'text',
|
|
157
|
+
label: 'Slippage Tolerance (%)',
|
|
158
|
+
value: slippage,
|
|
159
|
+
onChange: function onChange(e) {
|
|
160
|
+
return setSlippage(e.target.value);
|
|
161
|
+
},
|
|
162
|
+
placeholder: '0.5'
|
|
163
|
+
}
|
|
164
|
+
}],
|
|
165
|
+
onSubmit: handlePreview,
|
|
166
|
+
submitLabel: "Preview Exchange"
|
|
167
|
+
}), /*#__PURE__*/React.createElement(ExchangeRateCard, {
|
|
168
|
+
rate: rate,
|
|
169
|
+
loading: loadingRate
|
|
170
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
171
|
+
className: "flex flex-col gap-2 text-sm"
|
|
172
|
+
}, /*#__PURE__*/React.createElement("div", null, "Converted Amount: ", /*#__PURE__*/React.createElement("span", {
|
|
173
|
+
className: "font-mono"
|
|
174
|
+
}, converted, " ", destAsset)), /*#__PURE__*/React.createElement("div", null, "Slippage Impact: ", /*#__PURE__*/React.createElement("span", {
|
|
175
|
+
className: "font-mono"
|
|
176
|
+
}, impact)), /*#__PURE__*/React.createElement("div", null, "Estimated Fee: ", /*#__PURE__*/React.createElement("span", {
|
|
177
|
+
className: "font-mono"
|
|
178
|
+
}, fee, " XLM"))), preview && /*#__PURE__*/React.createElement("div", {
|
|
179
|
+
className: "bg-neutral-100 border rounded p-4 mt-2"
|
|
180
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
181
|
+
className: "font-bold mb-2"
|
|
182
|
+
}, "Order Preview"), /*#__PURE__*/React.createElement("div", null, "From: ", amount, " ", sourceAsset), /*#__PURE__*/React.createElement("div", null, "To: ", converted, " ", destAsset), /*#__PURE__*/React.createElement("div", null, "Rate: ", rate), /*#__PURE__*/React.createElement("div", null, "Slippage: ", slippage, "%"), /*#__PURE__*/React.createElement("div", null, "Fee: ", fee, " XLM"), /*#__PURE__*/React.createElement("div", null, "Impact: ", impact), /*#__PURE__*/React.createElement(Button, {
|
|
183
|
+
text: "Confirm Exchange",
|
|
184
|
+
variant: "primary",
|
|
185
|
+
onClick: function onClick() {
|
|
186
|
+
return alert('Exchange confirmed!');
|
|
187
|
+
}
|
|
188
|
+
})));
|
|
189
|
+
};
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
4
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
8
|
+
import { Form } from "../shared";
|
|
9
|
+
import { Button } from "../shared/elements/Button";
|
|
10
|
+
// SecurityLevelIndicator and BiometricPrompt are not found in the codebase, so we will create simple placeholders for them.
|
|
11
|
+
|
|
12
|
+
// Placeholder for SecurityLevelIndicator
|
|
13
|
+
var SecurityLevelIndicator = function SecurityLevelIndicator(_ref) {
|
|
14
|
+
var level = _ref.level;
|
|
15
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
16
|
+
className: "mb-4 p-2 rounded text-white ".concat(level === 'high' ? 'bg-red-600' : level === 'medium' ? 'bg-yellow-600' : 'bg-green-600')
|
|
17
|
+
}, "Security Level: ", level.charAt(0).toUpperCase() + level.slice(1));
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// Placeholder for BiometricPrompt
|
|
21
|
+
var BiometricPrompt = function BiometricPrompt(_ref2) {
|
|
22
|
+
var onAuthenticate = _ref2.onAuthenticate,
|
|
23
|
+
error = _ref2.error;
|
|
24
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
className: "flex flex-col items-center gap-2 my-4"
|
|
26
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
27
|
+
text: "Use Biometric",
|
|
28
|
+
variant: "secondary",
|
|
29
|
+
onClick: onAuthenticate
|
|
30
|
+
}), error && /*#__PURE__*/React.createElement("span", {
|
|
31
|
+
className: "text-red-500 text-xs"
|
|
32
|
+
}, error));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// Password strength checker
|
|
36
|
+
function getPasswordStrength(password) {
|
|
37
|
+
if (password.length > 11 && /[A-Z]/.test(password) && /[0-9]/.test(password) && /[^A-Za-z0-9]/.test(password)) return 'strong';
|
|
38
|
+
if (password.length > 7 && /[A-Z]/.test(password) && /[0-9]/.test(password)) return 'medium';
|
|
39
|
+
return 'weak';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Session timeout in seconds
|
|
43
|
+
var SESSION_TIMEOUT = 300; // 5 minutes
|
|
44
|
+
|
|
45
|
+
export var AuthenticationFlow = function AuthenticationFlow(_ref3) {
|
|
46
|
+
var riskLevel = _ref3.riskLevel,
|
|
47
|
+
twoFactorEnabled = _ref3.twoFactorEnabled,
|
|
48
|
+
biometricSupported = _ref3.biometricSupported,
|
|
49
|
+
onAuthenticated = _ref3.onAuthenticated;
|
|
50
|
+
var _useState = useState('password'),
|
|
51
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
52
|
+
step = _useState2[0],
|
|
53
|
+
setStep = _useState2[1];
|
|
54
|
+
var _useState3 = useState(''),
|
|
55
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
56
|
+
password = _useState4[0],
|
|
57
|
+
setPassword = _useState4[1];
|
|
58
|
+
var _useState5 = useState('weak'),
|
|
59
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
60
|
+
passwordStrength = _useState6[0],
|
|
61
|
+
setPasswordStrength = _useState6[1];
|
|
62
|
+
var _useState7 = useState(''),
|
|
63
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
64
|
+
passwordError = _useState8[0],
|
|
65
|
+
setPasswordError = _useState8[1];
|
|
66
|
+
var _useState9 = useState(''),
|
|
67
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
68
|
+
otp = _useState0[0],
|
|
69
|
+
setOtp = _useState0[1];
|
|
70
|
+
var _useState1 = useState(''),
|
|
71
|
+
_useState10 = _slicedToArray(_useState1, 2),
|
|
72
|
+
otpError = _useState10[0],
|
|
73
|
+
setOtpError = _useState10[1];
|
|
74
|
+
var _useState11 = useState(''),
|
|
75
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
76
|
+
biometricError = _useState12[0],
|
|
77
|
+
setBiometricError = _useState12[1];
|
|
78
|
+
var _useState13 = useState(SESSION_TIMEOUT),
|
|
79
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
80
|
+
sessionTime = _useState14[0],
|
|
81
|
+
setSessionTime = _useState14[1];
|
|
82
|
+
var timerRef = useRef(null);
|
|
83
|
+
|
|
84
|
+
// Update password strength
|
|
85
|
+
useEffect(function () {
|
|
86
|
+
setPasswordStrength(getPasswordStrength(password));
|
|
87
|
+
}, [password]);
|
|
88
|
+
|
|
89
|
+
// Session timeout logic
|
|
90
|
+
useEffect(function () {
|
|
91
|
+
if (step === 'done') return;
|
|
92
|
+
if (sessionTime === 0) {
|
|
93
|
+
setStep('password');
|
|
94
|
+
setPassword('');
|
|
95
|
+
setOtp('');
|
|
96
|
+
setPasswordError('Session timed out. Please authenticate again.');
|
|
97
|
+
setSessionTime(SESSION_TIMEOUT);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
timerRef.current = setTimeout(function () {
|
|
101
|
+
return setSessionTime(function (t) {
|
|
102
|
+
return t - 1;
|
|
103
|
+
});
|
|
104
|
+
}, 1000);
|
|
105
|
+
return function () {
|
|
106
|
+
return timerRef.current && clearTimeout(timerRef.current);
|
|
107
|
+
};
|
|
108
|
+
}, [sessionTime, step]);
|
|
109
|
+
|
|
110
|
+
// Handle password submission
|
|
111
|
+
var handlePasswordSubmit = function handlePasswordSubmit(e) {
|
|
112
|
+
e.preventDefault();
|
|
113
|
+
if (riskLevel === 'high' && passwordStrength !== 'strong') {
|
|
114
|
+
setPasswordError('Password must be strong for high-risk actions.');
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (passwordStrength === 'weak') {
|
|
118
|
+
setPasswordError('Password is too weak.');
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
setPasswordError('');
|
|
122
|
+
if (biometricSupported && riskLevel === 'low') {
|
|
123
|
+
setStep('biometric');
|
|
124
|
+
} else if (twoFactorEnabled && riskLevel !== 'low') {
|
|
125
|
+
setStep('2fa');
|
|
126
|
+
} else {
|
|
127
|
+
authenticateSuccess();
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// Handle OTP submission
|
|
132
|
+
var handleOtpSubmit = function handleOtpSubmit(e) {
|
|
133
|
+
e.preventDefault();
|
|
134
|
+
if (otp.length !== 6 || !/^[0-9]{6}$/.test(otp)) {
|
|
135
|
+
setOtpError('Invalid code.');
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
setOtpError('');
|
|
139
|
+
authenticateSuccess();
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// Handle biometric authentication
|
|
143
|
+
var handleBiometric = function handleBiometric() {
|
|
144
|
+
// Simulate biometric success/failure
|
|
145
|
+
var success = Math.random() > 0.2;
|
|
146
|
+
if (success) {
|
|
147
|
+
setBiometricError('');
|
|
148
|
+
authenticateSuccess();
|
|
149
|
+
} else {
|
|
150
|
+
setBiometricError('Biometric authentication failed. Try again or use password.');
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// On successful authentication
|
|
155
|
+
var authenticateSuccess = function authenticateSuccess() {
|
|
156
|
+
setStep('done');
|
|
157
|
+
onAuthenticated('session-token-' + Date.now());
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// Render security level indicator
|
|
161
|
+
var renderSecurityIndicator = function renderSecurityIndicator() {
|
|
162
|
+
return /*#__PURE__*/React.createElement(SecurityLevelIndicator, {
|
|
163
|
+
level: riskLevel
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// Render session timer
|
|
168
|
+
var renderSessionTimer = function renderSessionTimer() {
|
|
169
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
170
|
+
className: "text-xs text-neutral-500 mb-2"
|
|
171
|
+
}, "Session expires in ", Math.floor(sessionTime / 60), ":", (sessionTime % 60).toString().padStart(2, '0'));
|
|
172
|
+
};
|
|
173
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
174
|
+
className: "w-full max-w-md mx-auto bg-white rounded-xl shadow-md p-6 mt-4 flex flex-col gap-4"
|
|
175
|
+
}, renderSecurityIndicator(), renderSessionTimer(), step === 'password' && /*#__PURE__*/React.createElement(Form, {
|
|
176
|
+
fields: [{
|
|
177
|
+
field: {
|
|
178
|
+
type: 'password',
|
|
179
|
+
label: 'Password',
|
|
180
|
+
value: password,
|
|
181
|
+
onChange: function onChange(e) {
|
|
182
|
+
return setPassword(e.target.value);
|
|
183
|
+
},
|
|
184
|
+
error: passwordError,
|
|
185
|
+
placeholder: 'Enter your password'
|
|
186
|
+
}
|
|
187
|
+
}],
|
|
188
|
+
onSubmit: handlePasswordSubmit,
|
|
189
|
+
submitLabel: "Continue"
|
|
190
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
191
|
+
className: "mt-2"
|
|
192
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
193
|
+
className: "text-xs font-semibold ".concat(passwordStrength === 'strong' ? 'text-green-700' : passwordStrength === 'medium' ? 'text-yellow-700' : 'text-red-700')
|
|
194
|
+
}, "Strength: ", passwordStrength))), step === '2fa' && /*#__PURE__*/React.createElement(Form, {
|
|
195
|
+
fields: [{
|
|
196
|
+
field: {
|
|
197
|
+
type: 'text',
|
|
198
|
+
label: '2FA Code',
|
|
199
|
+
value: otp,
|
|
200
|
+
onChange: function onChange(e) {
|
|
201
|
+
return setOtp(e.target.value);
|
|
202
|
+
},
|
|
203
|
+
error: otpError,
|
|
204
|
+
placeholder: 'Enter 6-digit code',
|
|
205
|
+
maxLength: 6
|
|
206
|
+
}
|
|
207
|
+
}],
|
|
208
|
+
onSubmit: handleOtpSubmit,
|
|
209
|
+
submitLabel: "Verify"
|
|
210
|
+
}), step === 'biometric' && /*#__PURE__*/React.createElement(BiometricPrompt, {
|
|
211
|
+
onAuthenticate: handleBiometric,
|
|
212
|
+
error: biometricError
|
|
213
|
+
}), step === 'done' && /*#__PURE__*/React.createElement("div", {
|
|
214
|
+
className: "text-green-700 font-semibold text-center"
|
|
215
|
+
}, "Authenticated!"));
|
|
216
|
+
};
|