@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.
Files changed (304) hide show
  1. package/LICENSE +73 -0
  2. package/README.md +142 -0
  3. package/lib/assets/icons.js +67 -0
  4. package/lib/components/AccountOverview/AccountOverview.js +122 -0
  5. package/lib/components/AdminPanel.js +58 -0
  6. package/lib/components/AssetExchange/AssetExchange.js +189 -0
  7. package/lib/components/AuthenticationFlow.js +216 -0
  8. package/lib/components/ConversationInterface/ConversationInterface.js +232 -0
  9. package/lib/components/DevFooter.js +38 -0
  10. package/lib/components/DevMenu.js +35 -0
  11. package/lib/components/DevSidebar.js +28 -0
  12. package/lib/components/DigitalDisplay.js +83 -0
  13. package/lib/components/Footer.js +45 -0
  14. package/lib/components/HeroContainer.js +10 -0
  15. package/lib/components/IntentRecognition/IntentRecognition.js +174 -0
  16. package/lib/components/Logo.js +259 -0
  17. package/lib/components/MenuBar.js +56 -0
  18. package/lib/components/NetworkSettings.js +223 -0
  19. package/lib/components/RecoverySetup/RecoverySetup.js +354 -0
  20. package/lib/components/RisingSun.js +122 -0
  21. package/lib/components/Symbol.js +226 -0
  22. package/lib/components/TransactionComposer/TransactionComposer.js +258 -0
  23. package/lib/components/TransactionConfirmation.js +184 -0
  24. package/lib/components/WalletMenu.js +33 -0
  25. package/lib/components/console/code/CodeBlock.js +150 -0
  26. package/lib/components/console/code/index.js +9 -0
  27. package/lib/components/console/data/DataTable.js +245 -0
  28. package/lib/components/console/data/MetricCard.js +79 -0
  29. package/lib/components/console/data/index.js +11 -0
  30. package/lib/components/console/documentation/index.js +10 -0
  31. package/lib/components/console/forms/APIKeyGenerator.js +261 -0
  32. package/lib/components/console/forms/SearchBar.js +210 -0
  33. package/lib/components/console/forms/index.js +10 -0
  34. package/lib/components/console/index.js +29 -0
  35. package/lib/components/console/layout/ConsoleCard.js +82 -0
  36. package/lib/components/console/layout/ConsoleLayout.js +86 -0
  37. package/lib/components/console/layout/index.js +10 -0
  38. package/lib/components/console/monitoring/StatusIndicator.js +128 -0
  39. package/lib/components/console/monitoring/index.js +9 -0
  40. package/lib/components/console/navigation/DevFooter.js +38 -0
  41. package/lib/components/console/navigation/DevMenu.js +35 -0
  42. package/lib/components/console/navigation/DevSidebar.js +28 -0
  43. package/lib/components/console/navigation/index.js +11 -0
  44. package/lib/components/console/settings/index.js +10 -0
  45. package/lib/components/index.js +12 -0
  46. package/lib/design/ColorPicker.stories.js +9 -0
  47. package/lib/design/HSLTool-V1.js +345 -0
  48. package/lib/design/HSLTool-V2.js +475 -0
  49. package/lib/design/HSLTool-V3.js +543 -0
  50. package/lib/design/HSLTool-V4.js +1139 -0
  51. package/lib/design/HSLTool.js +374 -0
  52. package/lib/design/OKLCHColorPicker.stories.js +24 -0
  53. package/lib/design/OKLCHTool.js +1014 -0
  54. package/lib/index.js +4 -0
  55. package/lib/shared/components/Avatar/Avatar.js +18 -0
  56. package/lib/shared/components/Avatar/index.js +1 -0
  57. package/lib/shared/components/Badge/Badge.js +34 -0
  58. package/lib/shared/components/Badge/index.js +1 -0
  59. package/lib/shared/components/Breadcrumb/Breadcrumb.js +13 -0
  60. package/lib/shared/components/Breadcrumb/index.js +1 -0
  61. package/lib/shared/components/Button/Button.js +184 -0
  62. package/lib/shared/components/Button/index.js +1 -0
  63. package/lib/shared/components/Calendar/Calendar.js +155 -0
  64. package/lib/shared/components/Calendar/CalendarDay.js +251 -0
  65. package/lib/shared/components/Calendar/CalendarHeader.js +88 -0
  66. package/lib/shared/components/Calendar/CalendarMonth.js +106 -0
  67. package/lib/shared/components/Calendar/CalendarWeek.js +267 -0
  68. package/lib/shared/components/Calendar/constants.js +73 -0
  69. package/lib/shared/components/Calendar/index.js +3 -0
  70. package/lib/shared/components/Calendar/types.d.js +0 -0
  71. package/lib/shared/components/Cartel/Cartel.js +44 -0
  72. package/lib/shared/components/Cartel/index.js +1 -0
  73. package/lib/shared/components/Cell/Cell.js +105 -0
  74. package/lib/shared/components/Cell/index.js +1 -0
  75. package/lib/shared/components/Checkbox/Checkbox.js +27 -0
  76. package/lib/shared/components/Checkbox/index.js +1 -0
  77. package/lib/shared/components/Clock/Clock.js +6 -0
  78. package/lib/shared/components/Clock/index.js +1 -0
  79. package/lib/shared/components/ColorChecker/ColorChecker.js +89 -0
  80. package/lib/shared/components/ColorChecker/index.js +2 -0
  81. package/lib/shared/components/ColorChecker/utils.js +159 -0
  82. package/lib/shared/components/Command/Command.js +95 -0
  83. package/lib/shared/components/Command/index.js +1 -0
  84. package/lib/shared/components/Container/Container.js +18 -0
  85. package/lib/shared/components/Container/index.js +1 -0
  86. package/lib/shared/components/Cover/Cover.js +17 -0
  87. package/lib/shared/components/Cover/index.js +1 -0
  88. package/lib/shared/components/DatePicker/DatePicker.js +52 -0
  89. package/lib/shared/components/DatePicker/components/Calendar.js +125 -0
  90. package/lib/shared/components/DatePicker/components/CalendarDay.js +23 -0
  91. package/lib/shared/components/DatePicker/components/DateWrapper.js +15 -0
  92. package/lib/shared/components/DatePicker/components/index.js +2 -0
  93. package/lib/shared/components/DatePicker/index.js +1 -0
  94. package/lib/shared/components/DateTime/DateTime.js +51 -0
  95. package/lib/shared/components/DateTime/index.js +1 -0
  96. package/lib/shared/components/Debug/Debug.js +12 -0
  97. package/lib/shared/components/Debug/index.js +1 -0
  98. package/lib/shared/components/Disclosure/Disclosure.js +31 -0
  99. package/lib/shared/components/Disclosure/index.js +1 -0
  100. package/lib/shared/components/Dropdown/Dropdown.js +91 -0
  101. package/lib/shared/components/Dropdown/index.js +1 -0
  102. package/lib/shared/components/EmptyState/EmptyState.js +40 -0
  103. package/lib/shared/components/EmptyState/index.js +1 -0
  104. package/lib/shared/components/Form/Form.js +41 -0
  105. package/lib/shared/components/Form/components/DynamicForm.js +66 -0
  106. package/lib/shared/components/Form/components/StepperForm.js +266 -0
  107. package/lib/shared/components/Form/components/index.js +2 -0
  108. package/lib/shared/components/Form/context/Form.js +164 -0
  109. package/lib/shared/components/Form/context/index.js +1 -0
  110. package/lib/shared/components/Form/index.js +1 -0
  111. package/lib/shared/components/Form/types.d.js +1 -0
  112. package/lib/shared/components/Form/utils/index.js +31 -0
  113. package/lib/shared/components/GroupItems/GroupItems.js +17 -0
  114. package/lib/shared/components/GroupItems/index.js +1 -0
  115. package/lib/shared/components/Header/Header.js +26 -0
  116. package/lib/shared/components/Header/index.js +1 -0
  117. package/lib/shared/components/Heading/Heading.js +5 -0
  118. package/lib/shared/components/Heading/index.js +1 -0
  119. package/lib/shared/components/Icon/Icon.js +28 -0
  120. package/lib/shared/components/Icon/index.js +1 -0
  121. package/lib/shared/components/Identicons/Identicons.js +6 -0
  122. package/lib/shared/components/Identicons/index.d.js +0 -0
  123. package/lib/shared/components/Identicons/index.js +1 -0
  124. package/lib/shared/components/Image/Image.js +22 -0
  125. package/lib/shared/components/Image/index.js +1 -0
  126. package/lib/shared/components/Input/Input.js +201 -0
  127. package/lib/shared/components/Input/components/CheckBoxInput.js +81 -0
  128. package/lib/shared/components/Input/components/DateInput.js +89 -0
  129. package/lib/shared/components/Input/components/DefaultInput.js +102 -0
  130. package/lib/shared/components/Input/components/FileReaderInput.js +88 -0
  131. package/lib/shared/components/Input/components/NumberInput.js +141 -0
  132. package/lib/shared/components/Input/components/PickerInput.js +122 -0
  133. package/lib/shared/components/Input/components/RCInput.js +112 -0
  134. package/lib/shared/components/Input/components/Radiobox/RadioboxBasic.js +56 -0
  135. package/lib/shared/components/Input/components/Radiobox/RadioboxCard.js +27 -0
  136. package/lib/shared/components/Input/components/Radiobox/RadioboxFull.js +44 -0
  137. package/lib/shared/components/Input/components/Radiobox/index.js +3 -0
  138. package/lib/shared/components/Input/components/RadioboxInput.js +102 -0
  139. package/lib/shared/components/Input/components/SelectInput.js +70 -0
  140. package/lib/shared/components/Input/components/TextAreaInput.js +67 -0
  141. package/lib/shared/components/Input/components/TextInput.js +139 -0
  142. package/lib/shared/components/Input/components/TimeInput.js +37 -0
  143. package/lib/shared/components/Input/components/UploadFileInput.js +123 -0
  144. package/lib/shared/components/Input/components/index.js +13 -0
  145. package/lib/shared/components/Input/components/types.d.js +0 -0
  146. package/lib/shared/components/Input/index.js +1 -0
  147. package/lib/shared/components/Input/types.d.js +0 -0
  148. package/lib/shared/components/Layout/Layout.js +13 -0
  149. package/lib/shared/components/Layout/index.js +1 -0
  150. package/lib/shared/components/List/List.js +30 -0
  151. package/lib/shared/components/List/index.js +1 -0
  152. package/lib/shared/components/Loader/Loader.js +27 -0
  153. package/lib/shared/components/Loader/index.js +1 -0
  154. package/lib/shared/components/Modal/Modal.js +102 -0
  155. package/lib/shared/components/Modal/index.js +1 -0
  156. package/lib/shared/components/Notification/Notification.js +39 -0
  157. package/lib/shared/components/Notification/index.js +1 -0
  158. package/lib/shared/components/Person/Person.js +81 -0
  159. package/lib/shared/components/Person/index.js +1 -0
  160. package/lib/shared/components/Popover/Popover.js +39 -0
  161. package/lib/shared/components/Popover/index.js +1 -0
  162. package/lib/shared/components/QRCode/QRCode.js +329 -0
  163. package/lib/shared/components/QRCode/index.js +1 -0
  164. package/lib/shared/components/RadioGroup/RadioGroup.js +35 -0
  165. package/lib/shared/components/RadioGroup/components/DefaultGroup.js +71 -0
  166. package/lib/shared/components/RadioGroup/components/VerticalGroup.js +83 -0
  167. package/lib/shared/components/RadioGroup/components/index.js +2 -0
  168. package/lib/shared/components/RadioGroup/index.js +1 -0
  169. package/lib/shared/components/Search/Search.js +12 -0
  170. package/lib/shared/components/Search/index.js +1 -0
  171. package/lib/shared/components/Select/Select.js +90 -0
  172. package/lib/shared/components/Select/index.js +1 -0
  173. package/lib/shared/components/Sidebar/Sidebar.js +42 -0
  174. package/lib/shared/components/Sidebar/index.js +1 -0
  175. package/lib/shared/components/SlideOver/SlideOver.js +81 -0
  176. package/lib/shared/components/SlideOver/index.js +1 -0
  177. package/lib/shared/components/Slider/Slider.js +80 -0
  178. package/lib/shared/components/Slider/index.js +1 -0
  179. package/lib/shared/components/Stepper/Stepper.js +32 -0
  180. package/lib/shared/components/Stepper/index.js +1 -0
  181. package/lib/shared/components/Steps/Steps.js +53 -0
  182. package/lib/shared/components/Steps/index.js +1 -0
  183. package/lib/shared/components/Switch/Switch.js +26 -0
  184. package/lib/shared/components/Switch/index.js +1 -0
  185. package/lib/shared/components/Tab/Tab.js +59 -0
  186. package/lib/shared/components/Tab/index.js +1 -0
  187. package/lib/shared/components/Table/Table.js +47 -0
  188. package/lib/shared/components/Table/index.js +1 -0
  189. package/lib/shared/components/Text/Text.js +11 -0
  190. package/lib/shared/components/Text/index.js +1 -0
  191. package/lib/shared/components/TextList/TextList.js +15 -0
  192. package/lib/shared/components/TextList/index.js +1 -0
  193. package/lib/shared/components/TimePicker/TimePicker.js +161 -0
  194. package/lib/shared/components/TimePicker/index.js +1 -0
  195. package/lib/shared/components/Tooltip/Tooltip.js +13 -0
  196. package/lib/shared/components/Tooltip/index.js +1 -0
  197. package/lib/shared/components/Uploader/Uploader.js +63 -0
  198. package/lib/shared/components/Uploader/index.js +1 -0
  199. package/lib/shared/components/Video/Video.js +20 -0
  200. package/lib/shared/components/Video/index.js +1 -0
  201. package/lib/shared/components/index.d.js +0 -0
  202. package/lib/shared/components/index.js +50 -0
  203. package/lib/shared/elements/Color/ColorPallet.js +20 -0
  204. package/lib/shared/elements/Color/index.js +1 -0
  205. package/lib/shared/elements/Text.js +37 -0
  206. package/lib/shared/elements/index.js +1 -0
  207. package/lib/shared/helpers/FakeLink.js +8 -0
  208. package/lib/shared/helpers/constants.js +359 -0
  209. package/lib/shared/helpers/index.js +2 -0
  210. package/lib/shared/helpers/isEqual.js +56 -0
  211. package/lib/shared/index.d.js +0 -0
  212. package/lib/shared/index.js +1 -0
  213. package/lib/shared/stories/components/Avatar.stories.js +17 -0
  214. package/lib/shared/stories/components/Badge.stories.dev.js +37 -0
  215. package/lib/shared/stories/components/Button.stories.js +553 -0
  216. package/lib/shared/stories/components/Calendar.stories.js +62 -0
  217. package/lib/shared/stories/components/Cartel.stories.js +32 -0
  218. package/lib/shared/stories/components/Checkbox.stories.js +15 -0
  219. package/lib/shared/stories/components/ColorChecker.stories.dev.js +16 -0
  220. package/lib/shared/stories/components/DateTime.stories.js +27 -0
  221. package/lib/shared/stories/components/Disclosure.stories.js +30 -0
  222. package/lib/shared/stories/components/Dropdown.stories.js +39 -0
  223. package/lib/shared/stories/components/Form/Default.stories.js +201 -0
  224. package/lib/shared/stories/components/Form/DummyForm.stories.js +48 -0
  225. package/lib/shared/stories/components/Form/DynamicForm.stories.js +155 -0
  226. package/lib/shared/stories/components/Form/StepperForm.stories.js +138 -0
  227. package/lib/shared/stories/components/Form/ValidateForm.stories.js +70 -0
  228. package/lib/shared/stories/components/Form/Validation.stories.js +184 -0
  229. package/lib/shared/stories/components/GroupItems.stories.js +23 -0
  230. package/lib/shared/stories/components/Header.stories.js +29 -0
  231. package/lib/shared/stories/components/Heading.stories.js +27 -0
  232. package/lib/shared/stories/components/Icon.stories.js +22 -0
  233. package/lib/shared/stories/components/Image.stories.js +23 -0
  234. package/lib/shared/stories/components/Input/Checkbox.stories.js +45 -0
  235. package/lib/shared/stories/components/Input/DatePicker.stories.js +23 -0
  236. package/lib/shared/stories/components/Input/Defaut.stories.js +24 -0
  237. package/lib/shared/stories/components/Input/Number.stories.js +24 -0
  238. package/lib/shared/stories/components/Input/RCI.stories.js +59 -0
  239. package/lib/shared/stories/components/Input/Radiobox.stories.dev.js +28 -0
  240. package/lib/shared/stories/components/Input/Select.stories.dev.js +27 -0
  241. package/lib/shared/stories/components/Input/SelectMultiple.stories.dev.js +510 -0
  242. package/lib/shared/stories/components/Input/Textarea.stories.js +24 -0
  243. package/lib/shared/stories/components/List.stories.js +34 -0
  244. package/lib/shared/stories/components/Loader.stories.js +15 -0
  245. package/lib/shared/stories/components/Modal.stories.js +50 -0
  246. package/lib/shared/stories/components/Notification.stories.js +22 -0
  247. package/lib/shared/stories/components/Person.stories.js +41 -0
  248. package/lib/shared/stories/components/Picker.stories.js +15 -0
  249. package/lib/shared/stories/components/Popover.stories.js +36 -0
  250. package/lib/shared/stories/components/QRCode.stories.js +20 -0
  251. package/lib/shared/stories/components/RadioGroup.stories.js +56 -0
  252. package/lib/shared/stories/components/Select.stories.js +50 -0
  253. package/lib/shared/stories/components/Sidebar.stories.js +35 -0
  254. package/lib/shared/stories/components/Slider.stories.dev.js +48 -0
  255. package/lib/shared/stories/components/Stepper/Stepper.stories.js +38 -0
  256. package/lib/shared/stories/components/Steps.stories.js +15 -0
  257. package/lib/shared/stories/components/Switch.stories.js +15 -0
  258. package/lib/shared/stories/components/Tab.stories.js +15 -0
  259. package/lib/shared/stories/components/Table.stories.js +95 -0
  260. package/lib/shared/stories/components/TextList.stories.js +23 -0
  261. package/lib/shared/stories/components/Tooltip.stories.dev.js +40 -0
  262. package/lib/shared/stories/elements/Color.stories.js +269 -0
  263. package/lib/shared/stories/elements/Text.stories.js +45 -0
  264. package/lib/shared/types/index.js +1 -0
  265. package/lib/stories/Foundation/BrandIdentity.prod.stories.js +510 -0
  266. package/lib/stories/Foundation/Logo.stories.js +19 -0
  267. package/lib/stories/Foundation/RisingSun.stories.js +16 -0
  268. package/lib/stories/Foundation/Shadows.stories.js +601 -0
  269. package/lib/stories/Foundation/Symbol.stories.js +18 -0
  270. package/lib/stories/HeroContainer.stories.js +18 -0
  271. package/lib/styles/accessibilityTokens.js +72 -0
  272. package/lib/styles/borderWidth.js +10 -0
  273. package/lib/styles/colors.js +303 -0
  274. package/lib/styles/elevation.js +240 -0
  275. package/lib/styles/icons.js +218 -0
  276. package/lib/styles/index.js +29 -0
  277. package/lib/styles/motion.js +668 -0
  278. package/lib/styles/opacity.js +10 -0
  279. package/lib/styles/radius.js +11 -0
  280. package/lib/styles/sizing.js +35 -0
  281. package/lib/styles/space.js +24 -0
  282. package/lib/styles/theme/darkTheme.js +471 -0
  283. package/lib/styles/theme/index.js +44 -0
  284. package/lib/styles/theme/lightTheme.js +480 -0
  285. package/lib/styles/theme/themeTypes.js +1 -0
  286. package/lib/styles/theme/themeUtils.js +63 -0
  287. package/lib/styles/typography-advanced.js +510 -0
  288. package/lib/styles/typography.js +1419 -0
  289. package/lib/styles/zIndex.js +19 -0
  290. package/lib/tokens/borders.js +161 -0
  291. package/lib/tokens/colors.js +426 -0
  292. package/lib/tokens/components.js +499 -0
  293. package/lib/tokens/index.js +84 -0
  294. package/lib/tokens/lighting.js +384 -0
  295. package/lib/tokens/motion.js +284 -0
  296. package/lib/tokens/semantic.js +367 -0
  297. package/lib/tokens/shadows.js +114 -0
  298. package/lib/tokens/spacing.js +189 -0
  299. package/lib/tokens/typography.js +268 -0
  300. package/package.json +176 -0
  301. package/styles/generated-tokens.css +677 -0
  302. package/styles/index.css +2 -0
  303. package/styles/main.css +610 -0
  304. 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 from 'react';
8
+ import { Popover, Transition } from '@headlessui/react';
9
+ import { Button, Icon } from "../..";
10
+ import { Fragment } from 'react';
11
+ import { DateTime } from 'luxon';
12
+ export var PickerInput = function PickerInput(_ref) {
13
+ var Component = _ref.component,
14
+ config = _ref.config;
15
+ var id = config.id,
16
+ type = config.type,
17
+ style = config.style,
18
+ label = config.label,
19
+ icon = config.icon,
20
+ autoComplete = config.autoComplete,
21
+ placeholder = config.placeholder,
22
+ defaultValue = config.defaultValue,
23
+ uploadFile = config.uploadFile,
24
+ hidden = config.hidden,
25
+ debug = config.debug,
26
+ options = config.options,
27
+ required = config.required,
28
+ mRef = config.mRef;
29
+ var _React$useState = React.useState(undefined),
30
+ _React$useState2 = _slicedToArray(_React$useState, 2),
31
+ data = _React$useState2[0],
32
+ setData = _React$useState2[1];
33
+
34
+ // !!defaultValue ? (typeof defaultValue === 'number' ? new Date(defaultValue) : defaultValue) : new Date()
35
+ // const [date, setDate] = React.useState<Date>(!!defaultValue ? (typeof defaultValue === 'number' ? new Date(defaultValue) : defaultValue) : new Date());
36
+
37
+ var handleChange = function handleChange(data) {
38
+ setData(data);
39
+ };
40
+ React.useEffect(function () {
41
+ if (!!defaultValue) {
42
+ if (type === 'datepicker') {
43
+ // console.log('defaultValue', defaultValue.length)
44
+ var date = DateTime.fromSeconds(defaultValue / 1000).startOf('day');
45
+ var v = +new Date(date.toISO()) / 1000;
46
+ return setData({
47
+ name: "".concat(date.weekdayShort, " ").concat(date.day, " ").concat(date.monthLong),
48
+ value: v.toString()
49
+ });
50
+ }
51
+ // if (type === 'timepicker') return setData({name: startOfDay(defaultValue).toString(), value: formatISO(defaultValue, { representation: 'date' })});
52
+ } else {
53
+ if (type === 'datepicker') {
54
+ var _date = DateTime.fromJSDate(new Date()).startOf('day');
55
+ var _v = +new Date(_date.toISO()) / 1000;
56
+ return setData({
57
+ name: "".concat(_date.weekdayShort, " ").concat(_date.day, " ").concat(_date.monthLong),
58
+ value: _v.toString()
59
+ });
60
+ }
61
+ }
62
+ }, [defaultValue]);
63
+
64
+ // console.log("icon", icon)
65
+ // +new Date(startOfDay(date).toString())
66
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("label", {
67
+ htmlFor: id,
68
+ className: "block text-sm font-medium text-neutral-800"
69
+ }, label), /*#__PURE__*/React.createElement("input", {
70
+ type: "text",
71
+ value: data !== null && data !== void 0 && data.value ? data === null || data === void 0 ? void 0 : data.value : undefined,
72
+ hidden: debug ? !debug : true,
73
+ readOnly: true,
74
+ autoComplete: "off",
75
+ name: id,
76
+ id: id,
77
+ ref: mRef
78
+ }), /*#__PURE__*/React.createElement(Popover, {
79
+ className: "relative mt-1"
80
+ }, function (_ref2) {
81
+ var open = _ref2.open;
82
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Popover.Button, {
83
+ className: "\n border border-neutral-400 relative w-full shadow-sm py-2 pl-3 pr-10 text-left text-neutral-1600 bg-neutral-200 cursor-pointer sm:text-sm ".concat(!open ? 'rounded-[6px]' : 'rounded-[6px]')
84
+ }, /*#__PURE__*/React.createElement("span", {
85
+ className: "absolute inset-y-0 left-0 pl-2 flex items-center ".concat(!open ? 'text-neutral-1600' : 'text-primary-800')
86
+ }, /*#__PURE__*/React.createElement(Icon, {
87
+ name: icon
88
+ })), /*#__PURE__*/React.createElement("span", {
89
+ className: "pl-7 pr-12"
90
+ }, data === null || data === void 0 ? void 0 : data.name)), /*#__PURE__*/React.createElement(Transition, {
91
+ as: Fragment,
92
+ enter: "transition ease-out duration-300",
93
+ enterFrom: "opacity-0 translate-y-4",
94
+ enterTo: "opacity-100 translate-y-0",
95
+ leave: "transition ease-in duration-150",
96
+ leaveFrom: "opacity-100 translate-y-0",
97
+ leaveTo: "opacity-0 translate-y-4"
98
+ }, /*#__PURE__*/React.createElement(Popover.Panel, {
99
+ className: "absolute z-50 w-full"
100
+ }, /*#__PURE__*/React.createElement("div", {
101
+ className: "overflow-hidden"
102
+ }, /*#__PURE__*/React.createElement("div", {
103
+ className: "absolute bg-neutral-200 mt-[8px] p-[16px] rounded-[12px] border w-full"
104
+ }, /*#__PURE__*/React.createElement(Component, {
105
+ value: data === null || data === void 0 ? void 0 : data.value,
106
+ handleChange: handleChange,
107
+ defaultValue: defaultValue,
108
+ close: close
109
+ }), /*#__PURE__*/React.createElement(Popover.Button, {
110
+ onClick: function onClick() {
111
+ return close();
112
+ },
113
+ className: "w-full"
114
+ }, /*#__PURE__*/React.createElement(Button, {
115
+ text: "Close",
116
+ size: "tiny",
117
+ variant: "outline",
118
+ as: "div",
119
+ customCss: "w-full mt-4"
120
+ })))))));
121
+ })));
122
+ };
@@ -0,0 +1,112 @@
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 * as React from 'react';
8
+ import { useIsFocused } from 'use-is-focused';
9
+ import { CodeInput, getSegmentCssWidth } from 'rci';
10
+ import { Icon } from "../../Icon";
11
+ import clsx from 'clsx';
12
+ // import { CheckIcon, XIcon } from '@heroicons/react/solid';
13
+
14
+ // const checkCodeApiMock = (code: string, expected: string): Promise<boolean> => {
15
+ // return new Promise<boolean>((r) => setTimeout(r, 350, code === expected))
16
+ // }
17
+
18
+ var redirectToAppMock = function redirectToAppMock() {
19
+ alert('redirect to app');
20
+ // window.location.assign(window.location.href)
21
+ };
22
+ export var RCInput = function RCInput(_ref) {
23
+ var config = _ref.config;
24
+ var id = config.id,
25
+ label = config.label,
26
+ _config$maxLength = config.maxLength,
27
+ maxLength = _config$maxLength === void 0 ? 4 : _config$maxLength,
28
+ validation = config.validation;
29
+ var autoFocus = true;
30
+ var _React$useState = React.useState('input'),
31
+ _React$useState2 = _slicedToArray(_React$useState, 2),
32
+ state = _React$useState2[0],
33
+ setState = _React$useState2[1];
34
+ var inputRef = React.useRef(null);
35
+ var focused = useIsFocused(inputRef);
36
+ var width = getSegmentCssWidth('10px');
37
+ var TextStyle = clsx('text-neutral-1800', focused && 'border-primary-1600');
38
+ var InputStyle = clsx("border border-neutral-1600 rounded-[8px]", state === 'loading' && focused && 'border-primary-1600', state === 'success' && 'border-green-1600', state === 'error' && 'border-red-1600');
39
+ var iconStyle = clsx('pl-[20px] flex items-center text-neutral-1600', state === 'success' && 'text-green-1600', state === 'error' && 'text-red-1600');
40
+ React.useEffect(function () {
41
+ if (validation.state !== 'input') {
42
+ setState(validation.state);
43
+ if (validation.state === 'error') {
44
+ setTimeout(function () {
45
+ setState('input');
46
+ }, 500);
47
+ }
48
+ }
49
+ }, [validation.state]);
50
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
51
+ className: "flex"
52
+ }, /*#__PURE__*/React.createElement(CodeInput, {
53
+ id: id,
54
+ autoFocus: autoFocus,
55
+ className: TextStyle,
56
+ length: maxLength,
57
+ readOnly: state !== 'input',
58
+ disabled: state === 'loading',
59
+ inputRef: inputRef,
60
+ padding: "8px",
61
+ spacing: "16px",
62
+ spellCheck: false,
63
+ inputMode: "numeric",
64
+ pattern: "[0-9]*",
65
+ autoComplete: "one-time-code",
66
+ onChange: function onChange(_ref2) {
67
+ var input = _ref2.currentTarget;
68
+ // only accept numbers
69
+ input.value = input.value.replace(/\D+/g, '');
70
+
71
+ // auto submit on input fill
72
+ if (input.value.length === maxLength) {
73
+ setState('loading');
74
+ validation === null || validation === void 0 || validation.fn(input.value);
75
+ // .then((success: any) => {
76
+ // if (success) {
77
+ // setState('success')
78
+ // return setTimeout(redirectToAppMock, 500)
79
+ // }
80
+ // setState('error')
81
+ // setTimeout(() => {
82
+ // setState('input')
83
+ // input.value = ''
84
+ // input.dispatchEvent(new Event('input'))
85
+ // input.focus()
86
+ // }, 500)
87
+ // })
88
+ }
89
+ },
90
+ renderSegment: function renderSegment(_ref3) {
91
+ var state = _ref3.state,
92
+ index = _ref3.index;
93
+ return /*#__PURE__*/React.createElement("div", {
94
+ key: index,
95
+ className: InputStyle,
96
+ "data-state": state,
97
+ style: {
98
+ width: width,
99
+ height: '100%'
100
+ },
101
+ children: /*#__PURE__*/React.createElement("div", null)
102
+ });
103
+ }
104
+ }), /*#__PURE__*/React.createElement("div", {
105
+ className: iconStyle
106
+ }, state === 'loading' && /*#__PURE__*/React.createElement("div", {
107
+ className: "origin-center animate-spin"
108
+ }, /*#__PURE__*/React.createElement(Icon, {
109
+ name: "spinner",
110
+ size: "medium"
111
+ })))));
112
+ };
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+ import clsx from 'clsx';
3
+ import { RadioGroup } from '@headlessui/react';
4
+ export var RadioboxBasic = function RadioboxBasic(_ref) {
5
+ var options = _ref.options,
6
+ selected = _ref.selected,
7
+ handleUpdate = _ref.handleUpdate;
8
+ return /*#__PURE__*/React.createElement(RadioGroup, {
9
+ value: selected,
10
+ onChange: handleUpdate
11
+ }, /*#__PURE__*/React.createElement("div", {
12
+ className: "space-y-4"
13
+ }, options.map(function (item) {
14
+ return /*#__PURE__*/React.createElement(RadioGroup.Option, {
15
+ key: item.name,
16
+ value: item,
17
+ className: function className(_ref2) {
18
+ var checked = _ref2.checked;
19
+ return clsx('relative flex cursor-pointer focus:outline-none');
20
+ }
21
+ }, function (_ref3) {
22
+ var active = _ref3.active,
23
+ checked = _ref3.checked;
24
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
25
+ className: clsx(checked ? 'bg-primary-800' : 'border-gray-600', active ? 'ring-2 ring-offset-2 ring-primary-1000' : '', 'h-4 w-4 mt-0.5 cursor-pointer shrink-0 rounded-full border flex items-center justify-center'),
26
+ "aria-hidden": "true"
27
+ }, /*#__PURE__*/React.createElement("span", {
28
+ className: "rounded-full w-1.5 h-1.5"
29
+ })), /*#__PURE__*/React.createElement("span", {
30
+ className: "ml-3 flex flex-col"
31
+ }, /*#__PURE__*/React.createElement(RadioGroup.Label, {
32
+ as: "span",
33
+ className: clsx(checked ? 'text-primary-1800' : 'text-neutral-1800', 'ml-3 block text-sm font-medium text-neutral-1400')
34
+ }, item.name)));
35
+ });
36
+ })));
37
+ };
38
+
39
+ // <RadioGroup value={selected} onChange={handleUpdate}>
40
+ // <div className="space-y-4">
41
+ // {options.map((item: any) => (
42
+ // <div key={item.id} className="flex items-center">
43
+ // <input
44
+ // name='radioGroup'
45
+ // type="radio"
46
+ // checked={selected?.id === item.id}
47
+ // onChange={() => handleUpdate(item)}
48
+ // className="focus:ring-primary-800 h-4 w-4 text-primary-300 border-neutral-300"
49
+ // />
50
+ // <label htmlFor={item.id} className="ml-3 block text-sm font-medium text-neutral-700">
51
+ // {item.name}
52
+ // </label>
53
+ // </div>
54
+ // ))}
55
+ // </div>
56
+ // </RadioGroup>
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import clsx from 'clsx';
3
+ import { RadioGroup } from '@headlessui/react';
4
+ export var RadioboxCard = function RadioboxCard(_ref) {
5
+ var options = _ref.options,
6
+ selected = _ref.selected,
7
+ handleUpdate = _ref.handleUpdate;
8
+ return /*#__PURE__*/React.createElement(RadioGroup, {
9
+ value: selected,
10
+ onChange: handleUpdate,
11
+ className: "mt-2"
12
+ }, /*#__PURE__*/React.createElement("div", {
13
+ className: "grid grid-cols-3 gap-3 sm:grid-cols-6"
14
+ }, options.map(function (item) {
15
+ return /*#__PURE__*/React.createElement(RadioGroup.Option, {
16
+ key: item.name,
17
+ value: item,
18
+ className: function className(_ref2) {
19
+ var active = _ref2.active,
20
+ checked = _ref2.checked;
21
+ return clsx(active ? 'ring-2 ring-offset-2 ring-primary-1000' : '', checked ? 'border-primary-800 border-transparent text-neutral-800 hover:bg-primary-1400' : ' border-neutral-400 text-neutral-1200 hover:bg-neutral-200', 'border cursor-pointer rounded-md py-3 px-3 flex items-center justify-center text-sm font-medium uppercase sm:flex-1');
22
+ }
23
+ }, /*#__PURE__*/React.createElement(RadioGroup.Label, {
24
+ as: "span"
25
+ }, item.name));
26
+ })));
27
+ };
@@ -0,0 +1,44 @@
1
+ import React from 'react';
2
+ import clsx from 'clsx';
3
+ import { RadioGroup } from '@headlessui/react';
4
+ export var RadioboxFull = function RadioboxFull(_ref) {
5
+ var options = _ref.options,
6
+ selected = _ref.selected,
7
+ handleUpdate = _ref.handleUpdate;
8
+ // console.log('selected', selected)
9
+ return /*#__PURE__*/React.createElement(RadioGroup, {
10
+ value: selected,
11
+ onChange: handleUpdate
12
+ }, /*#__PURE__*/React.createElement("div", {
13
+ className: "space-y-4"
14
+ }, options.map(function (item) {
15
+ return /*#__PURE__*/React.createElement(RadioGroup.Option, {
16
+ key: item.name,
17
+ value: item,
18
+ className: function className(_ref2) {
19
+ var checked = _ref2.checked;
20
+ return clsx(
21
+ // itemIdx === 0 ? 'rounded-tl-md rounded-tr-md' : '',
22
+ // itemIdx === items.length - 1 ? 'rounded-bl-md rounded-br-md' : '',
23
+ checked ? 'z-10' : 'border-neutral-800', 'relative border p-4 flex cursor-pointer focus:outline-none rounded-[8px]');
24
+ }
25
+ }, function (_ref3) {
26
+ var active = _ref3.active,
27
+ checked = _ref3.checked;
28
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
29
+ className: clsx(checked ? 'bg-primary-800 border-transparent' : 'border-neutral-600', active ? 'ring-2 ring-offset-2 ring-primary-600' : '', 'h-4 w-4 mt-0.5 cursor-pointer shrink-0 rounded-full border flex items-center justify-center'),
30
+ "aria-hidden": "true"
31
+ }, /*#__PURE__*/React.createElement("span", {
32
+ className: "rounded-full bg-white w-1.5 h-1.5"
33
+ })), /*#__PURE__*/React.createElement("span", {
34
+ className: "ml-3 flex flex-col"
35
+ }, /*#__PURE__*/React.createElement(RadioGroup.Label, {
36
+ as: "span",
37
+ className: clsx(checked ? 'text-primary-800' : 'text-neutral-1800', 'block text-sm font-medium')
38
+ }, item.name), /*#__PURE__*/React.createElement(RadioGroup.Description, {
39
+ as: "span",
40
+ className: clsx(checked ? 'text-primary-600' : 'text-neutral-1000', 'block text-sm')
41
+ }, item.description)));
42
+ });
43
+ })));
44
+ };
@@ -0,0 +1,3 @@
1
+ export { RadioboxCard } from "./RadioboxCard";
2
+ export { RadioboxFull } from "./RadioboxFull";
3
+ export { RadioboxBasic } from "./RadioboxBasic";
@@ -0,0 +1,102 @@
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
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
3
+ 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."); }
4
+ 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; } }
5
+ 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; }
6
+ 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; } }
7
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
8
+ import React from 'react';
9
+ import { RadioboxBasic, RadioboxFull, RadioboxCard } from "./Radiobox";
10
+ export var RadioboxInput = function RadioboxInput(_ref) {
11
+ var config = _ref.config;
12
+ var id = config.id,
13
+ label = config.label,
14
+ variant = config.variant,
15
+ autoComplete = config.autoComplete,
16
+ placeholder = config.placeholder,
17
+ defaultValue = config.defaultValue,
18
+ options = config.options,
19
+ parentValue = config.parentValue,
20
+ afterChange = config.afterChange,
21
+ debug = config.debug,
22
+ required = config.required,
23
+ type = config.type,
24
+ mRef = config.mRef;
25
+ var _React$useState = React.useState(undefined),
26
+ _React$useState2 = _slicedToArray(_React$useState, 2),
27
+ selected = _React$useState2[0],
28
+ setSelected = _React$useState2[1];
29
+ var handleUpdate = function handleUpdate(event) {
30
+ setSelected(event);
31
+ if (!!afterChange) {
32
+ afterChange(event);
33
+ }
34
+ };
35
+ var getRadio = function getRadio(_ref2) {
36
+ var variant = _ref2.variant,
37
+ defaultValue = _ref2.defaultValue,
38
+ options = _ref2.options,
39
+ handleUpdate = _ref2.handleUpdate,
40
+ selected = _ref2.selected;
41
+ switch (variant) {
42
+ case 'full':
43
+ return /*#__PURE__*/React.createElement(RadioboxFull, {
44
+ selected: selected,
45
+ handleUpdate: handleUpdate,
46
+ options: options
47
+ });
48
+ case 'card':
49
+ return /*#__PURE__*/React.createElement(RadioboxCard, {
50
+ selected: selected,
51
+ handleUpdate: handleUpdate,
52
+ options: options
53
+ });
54
+ default:
55
+ return /*#__PURE__*/React.createElement(RadioboxBasic, {
56
+ selected: selected,
57
+ handleUpdate: handleUpdate,
58
+ options: options
59
+ });
60
+ }
61
+ };
62
+ React.useEffect(function () {
63
+ setSelected(!!defaultValue ? options.find(function (_ref3) {
64
+ var id = _ref3.id;
65
+ return id === defaultValue;
66
+ }) : options[0]);
67
+ if (!!afterChange) {
68
+ afterChange(options[0]);
69
+ }
70
+ }, [parentValue]);
71
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("label", {
72
+ className: "block text-sm font-medium text-neutral-900"
73
+ }, label), /*#__PURE__*/React.createElement("input", {
74
+ hidden: debug ? !debug : true,
75
+ value: selected === null || selected === void 0 ? void 0 : selected.value,
76
+ readOnly: true,
77
+ autoComplete: "off",
78
+ name: id,
79
+ id: id,
80
+ ref: mRef
81
+ }), /*#__PURE__*/React.createElement("fieldset", {
82
+ className: "mt-4"
83
+ }, getRadio({
84
+ variant: variant,
85
+ defaultValue: defaultValue,
86
+ options: options,
87
+ handleUpdate: handleUpdate,
88
+ selected: selected
89
+ })));
90
+ };
91
+ function CheckIcon(props) {
92
+ return /*#__PURE__*/React.createElement("svg", _extends({
93
+ viewBox: "0 0 24 24",
94
+ fill: "none"
95
+ }, props), /*#__PURE__*/React.createElement("path", {
96
+ d: "M7 13l3 3 7-7",
97
+ stroke: "#fff",
98
+ strokeWidth: 1.5,
99
+ strokeLinecap: "round",
100
+ strokeLinejoin: "round"
101
+ }));
102
+ }
@@ -0,0 +1,70 @@
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 from 'react';
8
+ import { Select } from "../../Select";
9
+ import { useForm } from "../../Form/context";
10
+ export var SelectInput = function SelectInput(_ref) {
11
+ var config = _ref.config;
12
+ var _useForm = useForm(),
13
+ updateForm = _useForm.updateForm;
14
+ var id = config.id,
15
+ label = config.label,
16
+ defaultValue = config.defaultValue,
17
+ options = config.options,
18
+ required = config.required,
19
+ debug = config.debug,
20
+ mRef = config.mRef,
21
+ belongs_to = config.belongs_to,
22
+ populateOptions = config.populateOptions,
23
+ multiple = config.multiple,
24
+ hidden = config.hidden;
25
+ var _React$useState = React.useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : ''),
26
+ _React$useState2 = _slicedToArray(_React$useState, 2),
27
+ value = _React$useState2[0],
28
+ setValue = _React$useState2[1];
29
+ React.useEffect(function () {
30
+ if (options.length === 0) {
31
+ // If there are no options, set value to empty string
32
+ setValue('');
33
+ } else {
34
+ // Check if current value exists in options
35
+ var hasValue = options.find(function (option) {
36
+ return "".concat(option.value) === value;
37
+ });
38
+ if (!hasValue) {
39
+ var _options$0$value;
40
+ // If not, set value to the first option's value
41
+ setValue((_options$0$value = options[0].value) !== null && _options$0$value !== void 0 ? _options$0$value : '');
42
+ }
43
+ }
44
+ }, [options]);
45
+ var handleChange = function handleChange(e) {
46
+ if ((e === null || e === void 0 ? void 0 : e.value) !== undefined) {
47
+ setValue("".concat(e.value));
48
+ updateForm();
49
+ }
50
+ };
51
+ return /*#__PURE__*/React.createElement(React.Fragment, null, !hidden && /*#__PURE__*/React.createElement("label", {
52
+ htmlFor: id,
53
+ className: "block text-sm font-medium text-neutral-800"
54
+ }, label), /*#__PURE__*/React.createElement("input", {
55
+ hidden: hidden ? true : !debug ? true : false,
56
+ value: value,
57
+ readOnly: true,
58
+ autoComplete: "off",
59
+ name: id,
60
+ id: id
61
+ }), !hidden && /*#__PURE__*/React.createElement(Select, {
62
+ id: id,
63
+ mRef: mRef,
64
+ afterUpdate: handleChange,
65
+ defaultValue: value,
66
+ debug: debug,
67
+ options: options ? options : [],
68
+ multiple: multiple
69
+ }));
70
+ };
@@ -0,0 +1,67 @@
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 { useForm } from "../../Form/context/Form";
13
+ export var TextAreaInput = function TextAreaInput(_ref) {
14
+ var config = _ref.config;
15
+ var id = config.id,
16
+ label = config.label,
17
+ autoComplete = config.autoComplete,
18
+ placeholder = config.placeholder,
19
+ defaultValue = config.defaultValue,
20
+ _config$maxLength = config.maxLength,
21
+ maxLength = _config$maxLength === void 0 ? 500 : _config$maxLength,
22
+ required = config.required;
23
+ var _useForm = useForm(),
24
+ updateForm = _useForm.updateForm;
25
+ var _React$useState = React.useState(0),
26
+ _React$useState2 = _slicedToArray(_React$useState, 2),
27
+ count = _React$useState2[0],
28
+ setCount = _React$useState2[1];
29
+ var validate = /*#__PURE__*/function () {
30
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
31
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
32
+ while (1) switch (_context.prev = _context.next) {
33
+ case 0:
34
+ setCount(event.target.value.length);
35
+ updateForm();
36
+ case 2:
37
+ case "end":
38
+ return _context.stop();
39
+ }
40
+ }, _callee);
41
+ }));
42
+ return function validate(_x) {
43
+ return _ref2.apply(this, arguments);
44
+ };
45
+ }();
46
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("label", {
47
+ htmlFor: id,
48
+ className: "block text-sm font-medium text-neutral-1600"
49
+ }, label), /*#__PURE__*/React.createElement("div", {
50
+ className: "mt-1"
51
+ }, /*#__PURE__*/React.createElement("textarea", {
52
+ id: id,
53
+ name: id,
54
+ rows: 3,
55
+ autoComplete: autoComplete,
56
+ maxLength: maxLength,
57
+ onChange: function onChange(e) {
58
+ return validate(e);
59
+ },
60
+ className: "resize-none shadow-sm focus:ring-primary-1000 focus:border-primary-1000 mt-1 block w-full text-neutral-1600 sm:text-sm border border-neutral-400 bg-neutral-200 rounded-md",
61
+ placeholder: placeholder,
62
+ defaultValue: defaultValue,
63
+ required: required
64
+ })), /*#__PURE__*/React.createElement("div", {
65
+ className: "text-primary-1000"
66
+ }, count, "/", maxLength)));
67
+ };