@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,91 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import { Menu, Transition } from '@headlessui/react';
|
|
3
|
+
import { Button } from '..';
|
|
4
|
+
import React, { Fragment } from 'react';
|
|
5
|
+
export var Dropdown = function Dropdown(_ref) {
|
|
6
|
+
var Component = _ref.component,
|
|
7
|
+
_ref$direction = _ref.direction,
|
|
8
|
+
direction = _ref$direction === void 0 ? 'right-bottom' : _ref$direction,
|
|
9
|
+
children = _ref.children,
|
|
10
|
+
button = _ref.button,
|
|
11
|
+
items = _ref.items;
|
|
12
|
+
var getPositionClass = function getPositionClass() {
|
|
13
|
+
switch (direction) {
|
|
14
|
+
case 'right-bottom':
|
|
15
|
+
return 'origin-top-right right-0';
|
|
16
|
+
case 'left-bottom':
|
|
17
|
+
return 'origin-top-left left-0';
|
|
18
|
+
case 'right-top':
|
|
19
|
+
return 'origin-bottom-right right-0';
|
|
20
|
+
case 'left-top':
|
|
21
|
+
return 'origin-bottom-left left-0';
|
|
22
|
+
case 'center-bottom':
|
|
23
|
+
return 'origin-center top-8 left-1/2 transform -translate-x-1/2';
|
|
24
|
+
default:
|
|
25
|
+
return 'origin-top-right right-0';
|
|
26
|
+
// Default position
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var icon = button.icon,
|
|
30
|
+
size = button.size;
|
|
31
|
+
// Add Color to Icon
|
|
32
|
+
// const iconName = icon ? { name: icon, size } : undefined;
|
|
33
|
+
return /*#__PURE__*/React.createElement(Menu, {
|
|
34
|
+
as: "div",
|
|
35
|
+
className: "relative inline-block text-left"
|
|
36
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, _extends({
|
|
37
|
+
type: "menu",
|
|
38
|
+
size: size,
|
|
39
|
+
icon: icon
|
|
40
|
+
}, button))), /*#__PURE__*/React.createElement(Transition, {
|
|
41
|
+
as: Fragment,
|
|
42
|
+
enter: "transition ease-out duration-100",
|
|
43
|
+
enterFrom: "transform opacity-0 scale-95",
|
|
44
|
+
enterTo: "transform opacity-100 scale-100",
|
|
45
|
+
leave: "transition ease-in duration-75",
|
|
46
|
+
leaveFrom: "transform opacity-100 scale-100",
|
|
47
|
+
leaveTo: "transform opacity-0 scale-95"
|
|
48
|
+
}, /*#__PURE__*/React.createElement(Menu.Items, {
|
|
49
|
+
className: "absolute right-0 w-56 mt-2 origin-top-right border border-neutral-400 divide-y divide-gray-100 rounded-md shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none z-50 ".concat(getPositionClass())
|
|
50
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
className: "relative py-[8px]"
|
|
52
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: "absolute top-0 bottom-0 right-0 left-0 rounded-md backdrop-blur-md bg-gradient-to-br from-neutral-200 to-300 opacity-[0.98] z-[-1]"
|
|
54
|
+
}), /*#__PURE__*/React.createElement("div", null, items.map(function (_ref2, key) {
|
|
55
|
+
var text = _ref2.text,
|
|
56
|
+
type = _ref2.type,
|
|
57
|
+
to = _ref2.to,
|
|
58
|
+
action = _ref2.action,
|
|
59
|
+
icon = _ref2.icon;
|
|
60
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
61
|
+
key: key
|
|
62
|
+
}, /*#__PURE__*/React.createElement(Menu.Item, {
|
|
63
|
+
as: "div"
|
|
64
|
+
}, function (_ref3) {
|
|
65
|
+
var active = _ref3.active;
|
|
66
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, type === 'button' && /*#__PURE__*/React.createElement(Button, {
|
|
67
|
+
text: text,
|
|
68
|
+
type: type,
|
|
69
|
+
variant: "dropdown",
|
|
70
|
+
active: active,
|
|
71
|
+
icon: icon,
|
|
72
|
+
onClick: action
|
|
73
|
+
}), type === 'action' && /*#__PURE__*/React.createElement(Button, {
|
|
74
|
+
text: text,
|
|
75
|
+
type: type,
|
|
76
|
+
to: to,
|
|
77
|
+
variant: "dropdown",
|
|
78
|
+
active: active,
|
|
79
|
+
icon: icon
|
|
80
|
+
}), type === 'link' && !!Component && /*#__PURE__*/React.createElement(Button, {
|
|
81
|
+
text: text,
|
|
82
|
+
type: "link",
|
|
83
|
+
variant: "dropdown",
|
|
84
|
+
icon: icon,
|
|
85
|
+
to: to,
|
|
86
|
+
active: active,
|
|
87
|
+
component: Component
|
|
88
|
+
}));
|
|
89
|
+
}));
|
|
90
|
+
}))))));
|
|
91
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Dropdown } from "./Dropdown";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export var EmptyState = function EmptyState(_ref) {
|
|
3
|
+
var _ref$size = _ref.size,
|
|
4
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
5
|
+
_ref$variant = _ref.variant,
|
|
6
|
+
variant = _ref$variant === void 0 ? 'basic' : _ref$variant,
|
|
7
|
+
customCss = _ref.customCss,
|
|
8
|
+
message = _ref.message,
|
|
9
|
+
CTA = _ref.CTA;
|
|
10
|
+
var _ref2 = message || {},
|
|
11
|
+
title = _ref2.title,
|
|
12
|
+
description = _ref2.description;
|
|
13
|
+
switch (variant) {
|
|
14
|
+
case 'basic':
|
|
15
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
16
|
+
className: "flex flex-row justify-center p-[20px] bg-neutral-100 rounded-[8px]"
|
|
17
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
className: "flex flex-col space-y-[20px] w-[200px] text-center"
|
|
19
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
20
|
+
className: "text-neutral-800"
|
|
21
|
+
}, title), /*#__PURE__*/React.createElement("div", {
|
|
22
|
+
className: "text-neutral-600"
|
|
23
|
+
}, description), /*#__PURE__*/React.createElement("div", null, CTA)));
|
|
24
|
+
case 'full':
|
|
25
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
className: "border border-neutral-100 rounded-[20px] text-neutral-800 flex flex-row justify-between max-w-[720px]"
|
|
27
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
28
|
+
className: "w-[300px] rounded-bl-[20px] rounded-tl-[20px] bg-cover bg-center",
|
|
29
|
+
style: {
|
|
30
|
+
backgroundImage: "linear-gradient(to right, rgba(255, 255, 255, 0), #1C181E), url('https://imagedelivery.net/uDbEDRBQqhBXrrfuCRrATQ/f583905b-d36c-49e6-0f3b-edc3d40b3c00/public')"
|
|
31
|
+
}
|
|
32
|
+
}), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
className: "flex flex-col space-y-[20px] p-[40px] "
|
|
34
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
35
|
+
className: "text-subheading-bold"
|
|
36
|
+
}, title), /*#__PURE__*/React.createElement("div", {
|
|
37
|
+
className: "text-p2-medium"
|
|
38
|
+
}, description), /*#__PURE__*/React.createElement("div", null, CTA))));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EmptyState } from "./EmptyState";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { DynamicForm, StepperForm } from "./components";
|
|
3
|
+
import { FormProvider } from "./context";
|
|
4
|
+
export var Form = function Form(_ref) {
|
|
5
|
+
var _ref$type = _ref.type,
|
|
6
|
+
type = _ref$type === void 0 ? 'default' : _ref$type,
|
|
7
|
+
id = _ref.id,
|
|
8
|
+
fields = _ref.fields,
|
|
9
|
+
action = _ref.action,
|
|
10
|
+
_ref$mode = _ref.mode,
|
|
11
|
+
mode = _ref$mode === void 0 ? 'action' : _ref$mode,
|
|
12
|
+
_ref$debug = _ref.debug,
|
|
13
|
+
debug = _ref$debug === void 0 ? false : _ref$debug,
|
|
14
|
+
button = _ref.button,
|
|
15
|
+
_ref$preventDefault = _ref.preventDefault,
|
|
16
|
+
preventDefault = _ref$preventDefault === void 0 ? true : _ref$preventDefault,
|
|
17
|
+
Component = _ref.component;
|
|
18
|
+
var childFormComponentProps = {
|
|
19
|
+
fields: fields,
|
|
20
|
+
button: button,
|
|
21
|
+
debug: debug,
|
|
22
|
+
action: mode === 'action' && typeof action === 'function' ? action : undefined
|
|
23
|
+
};
|
|
24
|
+
var providerProps = {
|
|
25
|
+
mode: mode,
|
|
26
|
+
fields: fields,
|
|
27
|
+
action: typeof action === 'function' ? action : undefined,
|
|
28
|
+
actionUrl: typeof action === 'string' ? action : undefined,
|
|
29
|
+
component: Component,
|
|
30
|
+
preventDefault: preventDefault,
|
|
31
|
+
debug: debug
|
|
32
|
+
};
|
|
33
|
+
return /*#__PURE__*/React.createElement(FormProvider, providerProps, id && /*#__PURE__*/React.createElement("input", {
|
|
34
|
+
type: "text",
|
|
35
|
+
hidden: true,
|
|
36
|
+
name: "id",
|
|
37
|
+
id: "id",
|
|
38
|
+
readOnly: true,
|
|
39
|
+
defaultValue: id
|
|
40
|
+
}), type === 'stepper' ? /*#__PURE__*/React.createElement(StepperForm, childFormComponentProps) : /*#__PURE__*/React.createElement(DynamicForm, childFormComponentProps));
|
|
41
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button, Input } from "../../index";
|
|
3
|
+
import { useForm } from "../context";
|
|
4
|
+
export var DynamicForm = function DynamicForm(_ref) {
|
|
5
|
+
var _ref$debug = _ref.debug,
|
|
6
|
+
debug = _ref$debug === void 0 ? false : _ref$debug,
|
|
7
|
+
button = _ref.button;
|
|
8
|
+
var _useForm = useForm(),
|
|
9
|
+
fieldsState = _useForm.fieldsState;
|
|
10
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
11
|
+
className: "space-y-4"
|
|
12
|
+
}, fieldsState.map(function (fields, key) {
|
|
13
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
14
|
+
key: key
|
|
15
|
+
}, fields.map(function (_ref2, key) {
|
|
16
|
+
var type = _ref2.type,
|
|
17
|
+
id = _ref2.id,
|
|
18
|
+
label = _ref2.label,
|
|
19
|
+
placeholder = _ref2.placeholder,
|
|
20
|
+
autoComplete = _ref2.autoComplete,
|
|
21
|
+
required = _ref2.required,
|
|
22
|
+
uploadFile = _ref2.uploadFile,
|
|
23
|
+
icon = _ref2.icon,
|
|
24
|
+
options = _ref2.options,
|
|
25
|
+
variant = _ref2.variant,
|
|
26
|
+
_ref2$hidden = _ref2.hidden,
|
|
27
|
+
hidden = _ref2$hidden === void 0 ? false : _ref2$hidden,
|
|
28
|
+
afterChange = _ref2.afterChange,
|
|
29
|
+
populateOptions = _ref2.populateOptions,
|
|
30
|
+
belongs_to = _ref2.belongs_to,
|
|
31
|
+
_ref2$disabled = _ref2.disabled,
|
|
32
|
+
disabled = _ref2$disabled === void 0 ? false : _ref2$disabled,
|
|
33
|
+
defaultValue = _ref2.defaultValue;
|
|
34
|
+
return /*#__PURE__*/React.createElement(Input, {
|
|
35
|
+
key: key,
|
|
36
|
+
type: type,
|
|
37
|
+
id: id,
|
|
38
|
+
disabled: disabled,
|
|
39
|
+
options: options,
|
|
40
|
+
label: label,
|
|
41
|
+
uploadFile: uploadFile,
|
|
42
|
+
hidden: hidden,
|
|
43
|
+
icon: icon,
|
|
44
|
+
variant: variant,
|
|
45
|
+
belongs_to: belongs_to,
|
|
46
|
+
populateOptions: populateOptions,
|
|
47
|
+
debug: debug,
|
|
48
|
+
defaultValue: !!defaultValue ? defaultValue : '',
|
|
49
|
+
autoComplete: autoComplete,
|
|
50
|
+
placeholder: placeholder,
|
|
51
|
+
required: required
|
|
52
|
+
});
|
|
53
|
+
}));
|
|
54
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
55
|
+
className: "pt-6"
|
|
56
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
57
|
+
text: button.text,
|
|
58
|
+
type: "submit",
|
|
59
|
+
rounded: "medium",
|
|
60
|
+
size: button.size,
|
|
61
|
+
icon: button.icon,
|
|
62
|
+
loading: button.loading,
|
|
63
|
+
variant: button.variant,
|
|
64
|
+
customCss: button.customCss
|
|
65
|
+
})));
|
|
66
|
+
};
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { return Object.defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = Object.getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l); function g(t) { ["next", "throw", "return"].forEach(function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, !0); } function d(r, e) { var n = e.method, o = r.i[n]; if (o === t) return e.delegate = null, "throw" === n && r.i["return"] && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e; return e.value = t, e.done = !0, e; }; return a.next = a; } } throw new TypeError(_typeof(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t; return t.done = !0, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), !1; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), !0; if (u < h) return n(h), !1; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, "catch": function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; }
|
|
3
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
4
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
5
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
6
|
+
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."); }
|
|
7
|
+
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; } }
|
|
8
|
+
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; }
|
|
9
|
+
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; } }
|
|
10
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { Button, Input } from "../../index";
|
|
13
|
+
import { useForm } from "../context";
|
|
14
|
+
import clsx from 'clsx';
|
|
15
|
+
export var StepperForm = function StepperForm(_ref) {
|
|
16
|
+
var fields = _ref.fields,
|
|
17
|
+
_ref$debug = _ref.debug,
|
|
18
|
+
debug = _ref$debug === void 0 ? false : _ref$debug,
|
|
19
|
+
button = _ref.button;
|
|
20
|
+
var maxStep = fields.length - 1;
|
|
21
|
+
var _React$useState = React.useState(0),
|
|
22
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
23
|
+
step = _React$useState2[0],
|
|
24
|
+
setStep = _React$useState2[1];
|
|
25
|
+
var _useForm = useForm(),
|
|
26
|
+
fieldsState = _useForm.fieldsState,
|
|
27
|
+
updateForm = _useForm.updateForm,
|
|
28
|
+
formState = _useForm.formState;
|
|
29
|
+
var _React$useState3 = React.useState(null),
|
|
30
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
31
|
+
validation = _React$useState4[0],
|
|
32
|
+
setValidation = _React$useState4[1];
|
|
33
|
+
var _React$useState5 = React.useState(false),
|
|
34
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
35
|
+
allowance = _React$useState6[0],
|
|
36
|
+
setAllowance = _React$useState6[1];
|
|
37
|
+
var nextStep = function nextStep(_ref2) {
|
|
38
|
+
var key = _ref2.key;
|
|
39
|
+
if (step <= maxStep) {
|
|
40
|
+
setStep(step + 1);
|
|
41
|
+
setAllowance(false);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// This effect checks for Input validations updates on every onChange
|
|
46
|
+
React.useEffect(function () {
|
|
47
|
+
if (fieldsState.length > 0 && step !== fieldsState.length) {
|
|
48
|
+
_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
49
|
+
var validationState, result;
|
|
50
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
51
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
52
|
+
case 0:
|
|
53
|
+
// Validating all fields in the current step
|
|
54
|
+
validationState = fieldsState[step].map(/*#__PURE__*/function () {
|
|
55
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(field, key) {
|
|
56
|
+
var _field$validation;
|
|
57
|
+
var _formState$find, value;
|
|
58
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
59
|
+
while (1) switch (_context.prev = _context.next) {
|
|
60
|
+
case 0:
|
|
61
|
+
if (!(((_field$validation = field.validation) === null || _field$validation === void 0 ? void 0 : _field$validation.fn) === undefined)) {
|
|
62
|
+
_context.next = 2;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
return _context.abrupt("return", true);
|
|
66
|
+
case 2:
|
|
67
|
+
if (!(formState === null)) {
|
|
68
|
+
_context.next = 4;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
return _context.abrupt("return", false);
|
|
72
|
+
case 4:
|
|
73
|
+
// Get the value of the field from the formState
|
|
74
|
+
_formState$find = formState.find(function (_ref5) {
|
|
75
|
+
var id = _ref5.id;
|
|
76
|
+
return id === field.id;
|
|
77
|
+
}), value = _formState$find.value;
|
|
78
|
+
console.log('value', value);
|
|
79
|
+
// Run the validation function
|
|
80
|
+
_context.next = 8;
|
|
81
|
+
return field.validation.fn(value);
|
|
82
|
+
case 8:
|
|
83
|
+
return _context.abrupt("return", _context.sent);
|
|
84
|
+
case 9:
|
|
85
|
+
case "end":
|
|
86
|
+
return _context.stop();
|
|
87
|
+
}
|
|
88
|
+
}, _callee);
|
|
89
|
+
}));
|
|
90
|
+
return function (_x, _x2) {
|
|
91
|
+
return _ref4.apply(this, arguments);
|
|
92
|
+
};
|
|
93
|
+
}()); // Wait for all validations to finish
|
|
94
|
+
_context2.next = 3;
|
|
95
|
+
return Promise.all(validationState);
|
|
96
|
+
case 3:
|
|
97
|
+
result = _context2.sent;
|
|
98
|
+
console.log('RESULT', result);
|
|
99
|
+
// Allow to continue to next step if all validations are true
|
|
100
|
+
setAllowance(result.every(function (e) {
|
|
101
|
+
return e === true || e.valid === true;
|
|
102
|
+
}));
|
|
103
|
+
case 6:
|
|
104
|
+
case "end":
|
|
105
|
+
return _context2.stop();
|
|
106
|
+
}
|
|
107
|
+
}, _callee2);
|
|
108
|
+
}))();
|
|
109
|
+
}
|
|
110
|
+
// validate every time the formState changes
|
|
111
|
+
}, [formState, allowance]);
|
|
112
|
+
var goBack = function goBack() {
|
|
113
|
+
if (step >= 1) {
|
|
114
|
+
setStep(step + -1);
|
|
115
|
+
setAllowance(true);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
var barContainer = clsx("grid gap-[4px] grid-cols-".concat(maxStep + 2));
|
|
119
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, step === fieldsState.length ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
120
|
+
className: "text-subheading-bold text-neutral-800 mb-[20px]"
|
|
121
|
+
}, "Review details"), /*#__PURE__*/React.createElement("div", {
|
|
122
|
+
className: "space-y-[8px]"
|
|
123
|
+
}, fieldsState.map(function (fields, key) {
|
|
124
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
125
|
+
key: key
|
|
126
|
+
}, fields.map(function (_ref6, key) {
|
|
127
|
+
var id = _ref6.id,
|
|
128
|
+
label = _ref6.label;
|
|
129
|
+
// console.log('id', label)
|
|
130
|
+
var _formState$find2 = formState.find(function (_ref7) {
|
|
131
|
+
var formId = _ref7.id;
|
|
132
|
+
return formId === id;
|
|
133
|
+
}),
|
|
134
|
+
value = _formState$find2.value;
|
|
135
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
136
|
+
key: key
|
|
137
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
138
|
+
className: "text-neutral-800"
|
|
139
|
+
}, label, ": ", value));
|
|
140
|
+
}));
|
|
141
|
+
}), formState.map(function (_ref8, key) {
|
|
142
|
+
var id = _ref8.id,
|
|
143
|
+
value = _ref8.value;
|
|
144
|
+
return /*#__PURE__*/React.createElement("input", {
|
|
145
|
+
key: key,
|
|
146
|
+
hidden: true,
|
|
147
|
+
id: id,
|
|
148
|
+
name: id,
|
|
149
|
+
defaultValue: value
|
|
150
|
+
});
|
|
151
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
152
|
+
className: "pt-6 flex flex-col space-y-[20px]"
|
|
153
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
154
|
+
className: "flex flex-row justify-start space-x-[8px]"
|
|
155
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
156
|
+
text: button.text,
|
|
157
|
+
type: "submit",
|
|
158
|
+
rounded: "medium",
|
|
159
|
+
variant: button.variant,
|
|
160
|
+
customCss: button.customCss
|
|
161
|
+
}), /*#__PURE__*/React.createElement(Button, {
|
|
162
|
+
onClick: function onClick() {
|
|
163
|
+
return goBack();
|
|
164
|
+
},
|
|
165
|
+
text: "back",
|
|
166
|
+
variant: "basic"
|
|
167
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
168
|
+
className: "flex flex-col space-y-[8px]"
|
|
169
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", {
|
|
170
|
+
className: "text-green-400 text-p2-bold"
|
|
171
|
+
}, step), /*#__PURE__*/React.createElement("span", {
|
|
172
|
+
className: "text-green-200 text-p2-medium pl-[2px]"
|
|
173
|
+
}, "/", maxStep + 1)), /*#__PURE__*/React.createElement("div", {
|
|
174
|
+
className: barContainer
|
|
175
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
176
|
+
className: "bg-green-400 rounded-[2px] h-[4px] col-span-".concat(step + 1)
|
|
177
|
+
}))))) : /*#__PURE__*/React.createElement("div", {
|
|
178
|
+
className: "flex flex-col justify-between h-[420px]"
|
|
179
|
+
}, fieldsState.map(function (fields, key) {
|
|
180
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
181
|
+
className: step !== key ? 'hidden' : 'flex flex-col space-y-[12px]'
|
|
182
|
+
}, fields.map(function (_ref9) {
|
|
183
|
+
var type = _ref9.type,
|
|
184
|
+
id = _ref9.id,
|
|
185
|
+
label = _ref9.label,
|
|
186
|
+
placeholder = _ref9.placeholder,
|
|
187
|
+
autoComplete = _ref9.autoComplete,
|
|
188
|
+
required = _ref9.required,
|
|
189
|
+
icon = _ref9.icon,
|
|
190
|
+
uploadFile = _ref9.uploadFile,
|
|
191
|
+
options = _ref9.options,
|
|
192
|
+
_ref9$hidden = _ref9.hidden,
|
|
193
|
+
hidden = _ref9$hidden === void 0 ? false : _ref9$hidden,
|
|
194
|
+
afterChange = _ref9.afterChange,
|
|
195
|
+
validation = _ref9.validation,
|
|
196
|
+
maxLength = _ref9.maxLength,
|
|
197
|
+
variant = _ref9.variant,
|
|
198
|
+
populateOptions = _ref9.populateOptions,
|
|
199
|
+
belongs_to = _ref9.belongs_to,
|
|
200
|
+
_ref9$disabled = _ref9.disabled,
|
|
201
|
+
disabled = _ref9$disabled === void 0 ? false : _ref9$disabled,
|
|
202
|
+
defaultValue = _ref9.defaultValue,
|
|
203
|
+
title = _ref9.title,
|
|
204
|
+
description = _ref9.description,
|
|
205
|
+
multiple = _ref9.multiple;
|
|
206
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, title && /*#__PURE__*/React.createElement("div", {
|
|
207
|
+
className: "text-subheading-bold text-neutral-800"
|
|
208
|
+
}, title), description && /*#__PURE__*/React.createElement("div", {
|
|
209
|
+
className: "text-p3-medium text-neutral-400"
|
|
210
|
+
}, description), /*#__PURE__*/React.createElement(Input, {
|
|
211
|
+
key: key,
|
|
212
|
+
type: type,
|
|
213
|
+
id: id,
|
|
214
|
+
disabled: disabled,
|
|
215
|
+
label: label,
|
|
216
|
+
options: options,
|
|
217
|
+
afterChange: type === 'select' || type === 'radiobox' ? afterChange : setValidation,
|
|
218
|
+
maxLength: maxLength,
|
|
219
|
+
variant: variant,
|
|
220
|
+
uploadFile: uploadFile,
|
|
221
|
+
icon: icon,
|
|
222
|
+
validation: validation,
|
|
223
|
+
belongs_to: belongs_to,
|
|
224
|
+
populateOptions: populateOptions,
|
|
225
|
+
hidden: step !== key ? true : hidden,
|
|
226
|
+
debug: debug,
|
|
227
|
+
defaultValue: !!defaultValue ? defaultValue : '',
|
|
228
|
+
autoComplete: autoComplete,
|
|
229
|
+
placeholder: placeholder,
|
|
230
|
+
required: required,
|
|
231
|
+
multiple: multiple
|
|
232
|
+
}));
|
|
233
|
+
})));
|
|
234
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
235
|
+
className: "pt-6 flex flex-col space-y-[20px]"
|
|
236
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
237
|
+
className: "flex flex-row justify-start space-x-[8px]"
|
|
238
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
239
|
+
onClick: function onClick() {
|
|
240
|
+
return nextStep({
|
|
241
|
+
data: fields
|
|
242
|
+
});
|
|
243
|
+
},
|
|
244
|
+
text: "next",
|
|
245
|
+
variant: "primary",
|
|
246
|
+
disabled: !Boolean(allowance)
|
|
247
|
+
}), step >= 1 && /*#__PURE__*/React.createElement(Button, {
|
|
248
|
+
onClick: function onClick() {
|
|
249
|
+
return goBack();
|
|
250
|
+
},
|
|
251
|
+
text: "back",
|
|
252
|
+
variant: "basic"
|
|
253
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
254
|
+
className: "flex flex-col space-y-[8px]"
|
|
255
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("span", {
|
|
256
|
+
className: "text-neutral-800 text-p2-bold"
|
|
257
|
+
}, step + 1), /*#__PURE__*/React.createElement("span", {
|
|
258
|
+
className: "text-neutral-400 text-p2-medium pl-[2px]"
|
|
259
|
+
}, "/", maxStep + 1)), /*#__PURE__*/React.createElement("div", {
|
|
260
|
+
className: barContainer
|
|
261
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
262
|
+
className: "bg-primary-400 rounded-[2px] h-[4px] col-span-".concat(step + 1)
|
|
263
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
264
|
+
className: "bg-neutral-400 rounded-[2px] h-[4px] col-span-".concat(maxStep - step + 1)
|
|
265
|
+
}))))));
|
|
266
|
+
};
|