@apple-pie/slice 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/chunks/Avatar-8-wPWe0V.js +68 -0
- package/dist/cjs/chunks/AvatarGroup-CVKmgBbD.js +39 -0
- package/dist/cjs/chunks/Badge-CMapJCij.js +41 -0
- package/dist/cjs/chunks/CheckBox-7AACxrdZ.js +76 -0
- package/dist/cjs/chunks/DivInput-BKKJTFeV.js +204 -0
- package/dist/cjs/chunks/DocIcons-BRWOzK96.js +41 -0
- package/dist/cjs/chunks/Dot-Dnr9M9na.js +80 -0
- package/dist/cjs/chunks/DrggablePanel-C6TPsDB-.js +302 -0
- package/dist/cjs/chunks/DropDown-D9sf_m2I.js +154 -0
- package/dist/cjs/chunks/EditorButtonBar-CUNDgRQd.js +244 -0
- package/dist/cjs/chunks/ErrorSummary-Dv44onsV.js +42 -0
- package/dist/cjs/chunks/FlexDiv-DZBpswHV.js +103 -0
- package/dist/cjs/chunks/Grouper-_kd2nU78.js +50 -0
- package/dist/cjs/chunks/IconButton-BfsPlKTb.js +84 -0
- package/dist/cjs/chunks/Logos-DSlAUz8l.js +119 -0
- package/dist/cjs/chunks/MessageInput-CiHFo2j8.js +399 -0
- package/dist/cjs/chunks/Overlay-DwCPvGB5.js +45 -0
- package/dist/cjs/chunks/Pager-CFtZ0IIW.js +42 -0
- package/dist/cjs/chunks/ProgressIndicator-C5oB7Mky.js +121 -0
- package/dist/cjs/chunks/RadioButton-e_y2qiPE.js +65 -0
- package/dist/cjs/chunks/RadioButtonList-I81UwHmM.js +116 -0
- package/dist/cjs/chunks/Slider-C-gn7Sby.js +285 -0
- package/dist/cjs/chunks/Spacer-BEY2-_PB.js +16 -0
- package/dist/cjs/chunks/Switch-CtkFtogd.js +43 -0
- package/dist/cjs/chunks/TabBar-D3bj4pjj.js +176 -0
- package/dist/cjs/chunks/TextArea-B1oKK3_b.js +153 -0
- package/dist/cjs/chunks/TextField-CiQdPP5E.js +248 -0
- package/dist/cjs/chunks/Tip-C2pzExut.js +91 -0
- package/dist/cjs/chunks/Toast-DrijUwoL.js +141 -0
- package/dist/cjs/chunks/UIButton-CH4p-8yq.js +317 -0
- package/dist/cjs/chunks/UIButtonBar-0fHPB0ww.js +58 -0
- package/dist/cjs/chunks/UICard-DBDSyT7E.js +36 -0
- package/dist/cjs/chunks/UIChip-kjhvRrOV.js +93 -0
- package/dist/cjs/chunks/UIFileIcon-ZrbDIeYz.js +54 -0
- package/dist/cjs/chunks/UILabel-DkBE2AIt.js +116 -0
- package/dist/cjs/chunks/_types-CoWzQFsT.js +714 -0
- package/dist/cjs/chunks/sharedTypes-BvTjh6M5.js +9 -0
- package/dist/cjs/chunks/style-inject.es-XZHJH68X.js +30 -0
- package/dist/cjs/chunks/tipStore-C9oV9SIh.js +23 -0
- package/dist/cjs/chunks/toastStore-C-ETP9H6.js +23 -0
- package/dist/cjs/chunks/tslib.es6-4H29ixHs.js +48 -0
- package/dist/cjs/chunks/utils-CbayehuI.js +126 -0
- package/dist/cjs/hooks/useDoubleClick.js +26 -0
- package/dist/cjs/hooks/useKeyboardShortcuts.js +42 -0
- package/dist/cjs/hooks/useLastUpdated.js +53 -0
- package/dist/cjs/hooks/useLocalStore.js +52 -0
- package/dist/cjs/hooks/useObserveResize.js +56 -0
- package/dist/cjs/hooks/useObserveTheme.js +37 -0
- package/dist/cjs/hooks/useTheme.js +86 -0
- package/dist/cjs/hooks/useToolTip.js +36 -0
- package/dist/cjs/hooks/useTrackRenders.js +38 -0
- package/dist/cjs/hooks/useWindow.js +64 -0
- package/dist/cjs/hooks.js +33 -0
- package/dist/cjs/index.js +124 -0
- package/dist/cjs/providers/ThemeProvider.js +55 -0
- package/dist/cjs/providers.js +14 -0
- package/dist/cjs/stores/tip.js +12 -0
- package/dist/cjs/stores/toast.js +12 -0
- package/dist/cjs/stores.js +18 -0
- package/dist/cjs/theme/colors.js +383 -0
- package/dist/cjs/theme/corners.js +14 -0
- package/dist/cjs/theme/elevations.js +17 -0
- package/dist/cjs/theme/themes.js +26 -0
- package/dist/cjs/theme/type.js +316 -0
- package/dist/cjs/theme.js +16 -0
- package/dist/cjs/uikit/Avatar.js +11 -0
- package/dist/cjs/uikit/AvatarGroup.js +12 -0
- package/dist/cjs/uikit/Badge.js +11 -0
- package/dist/cjs/uikit/CheckBox.js +22 -0
- package/dist/cjs/uikit/DivInput.js +13 -0
- package/dist/cjs/uikit/DocIcon.js +18 -0
- package/dist/cjs/uikit/Dot.js +12 -0
- package/dist/cjs/uikit/DraggablePanel.js +21 -0
- package/dist/cjs/uikit/DropDown.js +21 -0
- package/dist/cjs/uikit/EditorButtonBar.js +28 -0
- package/dist/cjs/uikit/ErrorSummary.js +12 -0
- package/dist/cjs/uikit/FlexDiv.js +12 -0
- package/dist/cjs/uikit/Grouper.js +23 -0
- package/dist/cjs/uikit/Icon.js +23 -0
- package/dist/cjs/uikit/IconButton.js +25 -0
- package/dist/cjs/uikit/Logos.js +18 -0
- package/dist/cjs/uikit/MessageInput.js +30 -0
- package/dist/cjs/uikit/Overlay.js +12 -0
- package/dist/cjs/uikit/Pager.js +12 -0
- package/dist/cjs/uikit/Progress.js +21 -0
- package/dist/cjs/uikit/RadioButton.js +26 -0
- package/dist/cjs/uikit/RadioButtonList.js +27 -0
- package/dist/cjs/uikit/Slider.js +13 -0
- package/dist/cjs/uikit/Spacer.js +10 -0
- package/dist/cjs/uikit/Switch.js +12 -0
- package/dist/cjs/uikit/TabBar.js +26 -0
- package/dist/cjs/uikit/TextArea.js +27 -0
- package/dist/cjs/uikit/Textfield.js +28 -0
- package/dist/cjs/uikit/Tip.js +13 -0
- package/dist/cjs/uikit/Toast.js +26 -0
- package/dist/cjs/uikit/UIButton.js +26 -0
- package/dist/cjs/uikit/UIButtonBar.js +26 -0
- package/dist/cjs/uikit/UICard.js +21 -0
- package/dist/cjs/uikit/UIChip.js +22 -0
- package/dist/cjs/uikit/UIFileIcon.js +18 -0
- package/dist/cjs/uikit/UILabel.js +19 -0
- package/dist/esm/chunks/Avatar-D_muqPrW.js +66 -0
- package/dist/esm/chunks/AvatarGroup-D8Xmrn52.js +37 -0
- package/dist/esm/chunks/Badge-PPf5Uvw3.js +39 -0
- package/dist/esm/chunks/CheckBox-CswFI0Xc.js +74 -0
- package/dist/esm/chunks/DivInput-iKFkeU2F.js +202 -0
- package/dist/esm/chunks/DocIcons-CbOX4n8Y.js +39 -0
- package/dist/esm/chunks/Dot-B84UVs2e.js +78 -0
- package/dist/esm/chunks/DrggablePanel-CYYwTmFd.js +300 -0
- package/dist/esm/chunks/DropDown-D4t6EhKL.js +152 -0
- package/dist/esm/chunks/EditorButtonBar-FnMa8Zv2.js +242 -0
- package/dist/esm/chunks/ErrorSummary-DhU5SKPt.js +40 -0
- package/dist/esm/chunks/FlexDiv-CmMpORgn.js +101 -0
- package/dist/esm/chunks/Grouper-BbreOXI9.js +48 -0
- package/dist/esm/chunks/IconButton-CguHGkBM.js +82 -0
- package/dist/esm/chunks/Logos-DwZP-TR2.js +117 -0
- package/dist/esm/chunks/MessageInput-DMHzCwjO.js +397 -0
- package/dist/esm/chunks/Overlay-CCBy7n7H.js +43 -0
- package/dist/esm/chunks/Pager-BsSti93V.js +40 -0
- package/dist/esm/chunks/ProgressIndicator-BVukxMU6.js +118 -0
- package/dist/esm/chunks/RadioButton-B5BxQI0R.js +63 -0
- package/dist/esm/chunks/RadioButtonList-C2z8McAD.js +114 -0
- package/dist/esm/chunks/Slider-C-PcWqTz.js +283 -0
- package/dist/esm/chunks/Spacer-DbZSG5x3.js +14 -0
- package/dist/esm/chunks/Switch-DjfrSiQz.js +41 -0
- package/dist/esm/chunks/TabBar-BSBcgTbd.js +174 -0
- package/dist/esm/chunks/TextArea-COM0UPo2.js +151 -0
- package/dist/esm/chunks/TextField-Bh24bRWs.js +246 -0
- package/dist/esm/chunks/Tip-Ct19Ljul.js +89 -0
- package/dist/esm/chunks/Toast-BR0oMX6z.js +139 -0
- package/dist/esm/chunks/UIButton-DKx-_O8h.js +315 -0
- package/dist/esm/chunks/UIButtonBar-BNdA5eVq.js +56 -0
- package/dist/esm/chunks/UICard-Dn5f3wg8.js +34 -0
- package/dist/esm/chunks/UIChip-DqnGeVyR.js +91 -0
- package/dist/esm/chunks/UIFileIcon-qGxIPsJJ.js +52 -0
- package/dist/esm/chunks/UILabel-RnbodPCS.js +114 -0
- package/dist/esm/chunks/_types-BaYeLEWK.js +712 -0
- package/dist/esm/chunks/sharedTypes-BfZzG1KX.js +9 -0
- package/dist/esm/chunks/style-inject.es-tgCJW-Cu.js +28 -0
- package/dist/esm/chunks/tipStore-nBYJ6tmE.js +17 -0
- package/dist/esm/chunks/toastStore-r3pvNa28.js +17 -0
- package/dist/esm/chunks/tslib.es6-0pkUdtrF.js +45 -0
- package/dist/esm/chunks/utils-BRZK2Drn.js +119 -0
- package/dist/esm/hooks/useDoubleClick.js +24 -0
- package/dist/esm/hooks/useKeyboardShortcuts.js +40 -0
- package/dist/esm/hooks/useLastUpdated.js +51 -0
- package/dist/esm/hooks/useLocalStore.js +50 -0
- package/dist/esm/hooks/useObserveResize.js +54 -0
- package/dist/esm/hooks/useObserveTheme.js +35 -0
- package/dist/esm/hooks/useTheme.js +84 -0
- package/dist/esm/hooks/useToolTip.js +34 -0
- package/dist/esm/hooks/useTrackRenders.js +36 -0
- package/dist/esm/hooks/useWindow.js +62 -0
- package/dist/esm/hooks.js +15 -0
- package/dist/esm/index.js +58 -0
- package/dist/esm/providers/ThemeProvider.js +53 -0
- package/dist/esm/providers.js +8 -0
- package/dist/esm/stores/tip.js +2 -0
- package/dist/esm/stores/toast.js +2 -0
- package/dist/esm/stores.js +3 -0
- package/dist/esm/theme/colors.js +377 -0
- package/dist/esm/theme/corners.js +12 -0
- package/dist/esm/theme/elevations.js +15 -0
- package/dist/esm/theme/themes.js +23 -0
- package/dist/esm/theme/type.js +312 -0
- package/dist/esm/theme.js +5 -0
- package/dist/esm/uikit/Avatar.js +5 -0
- package/dist/esm/uikit/AvatarGroup.js +6 -0
- package/dist/esm/uikit/Badge.js +5 -0
- package/dist/esm/uikit/CheckBox.js +16 -0
- package/dist/esm/uikit/DivInput.js +7 -0
- package/dist/esm/uikit/DocIcon.js +12 -0
- package/dist/esm/uikit/Dot.js +6 -0
- package/dist/esm/uikit/DraggablePanel.js +15 -0
- package/dist/esm/uikit/DropDown.js +15 -0
- package/dist/esm/uikit/EditorButtonBar.js +22 -0
- package/dist/esm/uikit/ErrorSummary.js +6 -0
- package/dist/esm/uikit/FlexDiv.js +6 -0
- package/dist/esm/uikit/Grouper.js +17 -0
- package/dist/esm/uikit/Icon.js +13 -0
- package/dist/esm/uikit/IconButton.js +19 -0
- package/dist/esm/uikit/Logos.js +12 -0
- package/dist/esm/uikit/MessageInput.js +24 -0
- package/dist/esm/uikit/Overlay.js +6 -0
- package/dist/esm/uikit/Pager.js +6 -0
- package/dist/esm/uikit/Progress.js +14 -0
- package/dist/esm/uikit/RadioButton.js +20 -0
- package/dist/esm/uikit/RadioButtonList.js +21 -0
- package/dist/esm/uikit/Slider.js +7 -0
- package/dist/esm/uikit/Spacer.js +4 -0
- package/dist/esm/uikit/Switch.js +6 -0
- package/dist/esm/uikit/TabBar.js +20 -0
- package/dist/esm/uikit/TextArea.js +21 -0
- package/dist/esm/uikit/Textfield.js +22 -0
- package/dist/esm/uikit/Tip.js +7 -0
- package/dist/esm/uikit/Toast.js +16 -0
- package/dist/esm/uikit/UIButton.js +20 -0
- package/dist/esm/uikit/UIButtonBar.js +20 -0
- package/dist/esm/uikit/UICard.js +15 -0
- package/dist/esm/uikit/UIChip.js +16 -0
- package/dist/esm/uikit/UIFileIcon.js +12 -0
- package/dist/esm/uikit/UILabel.js +13 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types/providers/ThemeProvider.d.ts +1 -0
- package/dist/types/stores/index.d.ts +2 -0
- package/dist/types/stores/tip/_types.d.ts +8 -0
- package/dist/types/stores/tip/index.d.ts +2 -0
- package/dist/types/stores/tip/tipStore.d.ts +12 -0
- package/dist/types/stores/toast/_types.d.ts +14 -0
- package/dist/types/stores/toast/index.d.ts +2 -0
- package/dist/types/stores/toast/toastStore.d.ts +12 -0
- package/dist/types/theme/elevations/_types.d.ts +10 -0
- package/dist/types/theme/elevations/elevations.d.ts +5 -0
- package/dist/types/theme/index.d.ts +2 -0
- package/dist/types/theme/themes.d.ts +2 -0
- package/dist/types/uikit/FlexDiv/FlexDiv.d.ts +2 -0
- package/dist/types/uikit/FlexDiv/_types.d.ts +1 -0
- package/dist/types/uikit/Toast/Toast.d.ts +1 -1
- package/dist/types/uikit/Toast/_types.d.ts +7 -1
- package/dist/types/uikit/Toast/index.d.ts +1 -1
- package/package.json +84 -5
- package/dist/index.esm.js +0 -5859
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js +0 -5911
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { _ as __rest } from './tslib.es6-0pkUdtrF.js';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { AnimatePresence, motion } from 'motion/react';
|
|
4
|
+
import React, { useRef, useState, useEffect, useCallback, useMemo } from 'react';
|
|
5
|
+
import { useTheme } from '../hooks/useTheme.js';
|
|
6
|
+
import '../theme/colors.js';
|
|
7
|
+
import '../hooks/useWindow.js';
|
|
8
|
+
import { I as Icon } from './_types-BaYeLEWK.js';
|
|
9
|
+
import { I as IconButton } from './IconButton-CguHGkBM.js';
|
|
10
|
+
import { U as UIButton } from './UIButton-DKx-_O8h.js';
|
|
11
|
+
import { s as styleInject } from './style-inject.es-tgCJW-Cu.js';
|
|
12
|
+
|
|
13
|
+
var css_248z = ".flexBox-module_row__PWxbe {\n\tdisplay: flex;\n\tjustify-content: center;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_rowBetween__27lKK {\n\tdisplay: flex;\n\tjustify-content: space-between;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_rowStart__nJZnW {\n\tdisplay: flex;\n\tjustify-content: flex-start;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_rowEnd__dHcOU {\n\tdisplay: flex;\n\tjustify-content: flex-end;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_column__MP2Xd {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: center;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnStart__Kg8cV {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: flex-start;\n\talign-items: flex-start;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnStartCenter__zcmtk {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: flex-start;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnBetween__157yI {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: space-between;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnEnd__u2nwI {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: flex-end;\n\talign-items: flex-end;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.type-module_body-xs-regular__QWEzl {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-regular);\n\tfont-size: var(--font-size-xs);\n\tline-height: 133.33%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_body-xs-medium__FxEAv {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-medium);\n\tfont-size: var(--font-size-xs);\n\tline-height: 133.33%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_body-xs-bold__rf7AV {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-bold);\n\tfont-size: var(--font-size-xs);\n\tline-height: 133.33%;\n\ttext-decoration: none;\n\tletter-spacing: 0.25px;\n}.type-module_body-s-regular__8-FO- {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-regular);\n\tfont-size: var(--font-size-s);\n\tline-height: 142.86%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_body-s-medium__qyYq- {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-medium);\n\tfont-size: var(--font-size-s);\n\tline-height: 142.86%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_body-s-bold__7GQ5Z {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-bold);\n\tfont-size: var(--font-size-s);\n\tline-height: 142.86%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_body-m-regular__Qtp5G {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-regular);\n\tfont-size: var(--font-size-m);\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_body-m-medium__Ieh9K {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-medium);\n\tfont-size: var(--font-size-m);\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_body-m-bold__0lZ3I {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-bold);\n\tfont-size: var(--font-size-m);\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_body-l-regular__Ar4d3 {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-regular);\n\tfont-size: var(--font-size-l);\n\tline-height: 162.5%;\n\ttext-decoration: none;\n\tletter-spacing: 0.1px;\n}.type-module_body-l-medium__6tV1n {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-medium);\n\tfont-size: var(--font-size-l);\n\tline-height: 162.5%;\n\ttext-decoration: none;\n\tletter-spacing: 0.1px;\n}.type-module_body-l-bold__I8Q1v {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-bold);\n\tfont-size: var(--font-size-l);\n\tline-height: 162.5%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_heading-s-bold__QFgN8 {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 650;\n\tfont-size: 20px;\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-s-medium__jGIb2 {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 560;\n\tfont-size: 20px;\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-m-bold__tdBSi {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 650;\n\tfont-size: 24px;\n\tline-height: 116.67%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-m-medium__-7Uyu {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 560;\n\tfont-size: 24px;\n\tline-height: 116.67%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-l-medium__8hGYF {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 560;\n\tfont-size: 28px;\n\tline-height: 128.57%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-l-bold__Cryjg {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 650;\n\tfont-size: 28px;\n\tline-height: 128.57%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}\n\n.TextField-module_wrapper__I0Av0 {\n\tposition: relative;\n\tpadding: var(--tf-padding) !important;\n\tgap: 8px;\n\toverflow: visible;\n\twidth: var(--tf-width);\n\theight: var(--tf-height);\n\tborder-radius: var(--tf-border-radius);\n\tbackground: var(--tf-bg);\n\tbox-shadow: var(--tf-box-shadow);\n\ttransition: all 0.25s ease-in-out 0s;\n}\n\n.TextField-module_container__0FwXa {\n\tflex: 1;\n\theight: 100%;\n\tgap: 8px;\n}\n\n.TextField-module_label__Jyh8E {\n\tcolor: var(--tf-label-color);\n\theight: auto;\n\toverflow: hidden;\n\twhite-space: nowrap;\n}\n\n.TextField-module_input__N140B {\n\tcolor: var(--tf-text-color);\n\tbackground-color: transparent;\n\tbox-sizing: border-box;\n\toutline: none;\n\tborder: 0;\n\theight: 100%;\n\twidth: 100%;\n\ttext-align: var(--tf-text-align);\n\t&::placeholder {\n\t\tcolor: var(--tf-placeholder-color);\n\t}\n\t&:focus::placeholder {\n\t\tcolor: var(--tf-placeholder-color);\n\t}\n\t&:disabled {\n\t\tcolor: var(--core-text-disabled);\n\t}\n\t&:-webkit-autofill,\n\t&:-webkit-autofill:hover,\n\t&:-webkit-autofill:focus,\n\t&:-webkit-autofill:active {\n\t\tbox-shadow: 0 0 0 50px var(--core-button-disabled) inset !important;\n\t\t-webkit-text-fill-color: var(--core-text-primary);\n\t}\n}\n\n.TextField-module_showPassword__Y-6u- {\n\tmin-height: 18px;\n\tmin-width: 18px;\n\tmax-height: 18px;\n\tmax-width: 18px;\n\topacity: var(--tf-show-opacity);\n\t&:hover {\n\t\topacity: var(--tf-show-opacity-hover);\n\t}\n}\n\n.TextField-module_s__sOwni {\n}\n\n.TextField-module_m__gsIsZ {\n}\n\n.TextField-module_l__f0HAD {\n}\n";
|
|
14
|
+
var css = {"wrapper":"TextField-module_wrapper__I0Av0 flexBox-module_rowStart__nJZnW","container":"TextField-module_container__0FwXa flexBox-module_rowStart__nJZnW","label":"TextField-module_label__Jyh8E flexBox-module_rowStart__nJZnW","input":"TextField-module_input__N140B","showPassword":"TextField-module_showPassword__Y-6u- flexBox-module_row__PWxbe","s":"TextField-module_s__sOwni type-module_body-s-regular__8-FO-","m":"TextField-module_m__gsIsZ type-module_body-m-regular__Qtp5G","l":"TextField-module_l__f0HAD type-module_body-l-regular__Ar4d3"};
|
|
15
|
+
styleInject(css_248z);
|
|
16
|
+
|
|
17
|
+
const MOTION_CONFIG = {
|
|
18
|
+
variants: {
|
|
19
|
+
initial: { opacity: 0 },
|
|
20
|
+
animate: { opacity: 1 },
|
|
21
|
+
exit: { opacity: 0 },
|
|
22
|
+
},
|
|
23
|
+
transition: { ease: 'easeInOut', duration: 0.25 },
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const TextField = React.memo((props) => {
|
|
27
|
+
const theme = useTheme();
|
|
28
|
+
const { name = 'input_name', value = '', label = '', labelSize = 'm', textSize = 'm', placeholder = 'placeholder', focused = false, onSubmit = () => null, onChange = () => null, onBlur = () => null, onFocus = () => null, onKeydown = () => null, onAction = () => null, onPaste = () => null, onClear = () => null, onValidate = () => null, actionButton = false, maxLength = undefined, size = { width: '100%', height: 'auto' }, padding = '8px 16px', borderRadius = 8, editable = true, textAlign = 'left', isValid = true, inline = false, noShow = false, borderType = 'box', validate = true, borderColor = {
|
|
29
|
+
focused: 'var(--core-link-primary)',
|
|
30
|
+
blurred: 'var(--core-outline-primary)',
|
|
31
|
+
error: 'var(--feedback-warning)',
|
|
32
|
+
}, backgroundColor = {
|
|
33
|
+
focused: 'var(--core-surface-secondary)',
|
|
34
|
+
blurred: 'var(--core-surface-secondary)',
|
|
35
|
+
}, color = {
|
|
36
|
+
focused: 'var(--core-text-primary)',
|
|
37
|
+
blurred: 'var(--core-text-primary)',
|
|
38
|
+
error: 'var(--feedback-warning)',
|
|
39
|
+
placeholder: 'var(--core-text-disabled)',
|
|
40
|
+
disabled: 'var(--core-text-disabled)',
|
|
41
|
+
label: 'var(--core-text-tertiary)',
|
|
42
|
+
}, iconLeft = null, clearButton = { size: 20 }, clearBlurs = false, disabled = false, inputType = 'text' } = props, divAttributes = __rest(props, ["name", "value", "label", "labelSize", "textSize", "placeholder", "focused", "onSubmit", "onChange", "onBlur", "onFocus", "onKeydown", "onAction", "onPaste", "onClear", "onValidate", "actionButton", "maxLength", "size", "padding", "borderRadius", "editable", "textAlign", "isValid", "inline", "noShow", "borderType", "validate", "borderColor", "backgroundColor", "color", "iconLeft", "clearButton", "clearBlurs", "disabled", "inputType"]);
|
|
43
|
+
const { id: divId, className, style } = divAttributes, rest = __rest(divAttributes, ["id", "className", "style"]);
|
|
44
|
+
const divStyle = style !== null && style !== void 0 ? style : {};
|
|
45
|
+
const divClass = className ? ` ${className}` : '';
|
|
46
|
+
const input = useRef(null);
|
|
47
|
+
const [text, setText] = useState(value);
|
|
48
|
+
const [isFocused, setIsFocused] = useState(focused);
|
|
49
|
+
const [valid, setValid] = useState(isValid);
|
|
50
|
+
const [show, setShow] = useState(false);
|
|
51
|
+
// update focused and blurred state on prop updates
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (!input.current)
|
|
54
|
+
return;
|
|
55
|
+
if (focused) {
|
|
56
|
+
input.current.focus();
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
input.current.blur();
|
|
60
|
+
}
|
|
61
|
+
setIsFocused(focused);
|
|
62
|
+
}, [focused]);
|
|
63
|
+
// update text value on prop change
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
setText(value);
|
|
66
|
+
}, [value]);
|
|
67
|
+
// update valid on prop change
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
setValid(isValid);
|
|
70
|
+
}, [isValid]);
|
|
71
|
+
// callback to check if the text is valid
|
|
72
|
+
const textIsValid = useCallback((entry) => {
|
|
73
|
+
if (!validate)
|
|
74
|
+
return;
|
|
75
|
+
const ok = entry.length > 1 || entry === '';
|
|
76
|
+
setValid(ok);
|
|
77
|
+
if (valid !== ok)
|
|
78
|
+
onValidate(ok);
|
|
79
|
+
}, [onValidate, valid, validate]);
|
|
80
|
+
// memo clear text field contents
|
|
81
|
+
const handleClearTextField = useCallback(() => {
|
|
82
|
+
if (input === null || input === void 0 ? void 0 : input.current) {
|
|
83
|
+
if (!clearBlurs)
|
|
84
|
+
input.current.focus();
|
|
85
|
+
setText('');
|
|
86
|
+
textIsValid('');
|
|
87
|
+
}
|
|
88
|
+
onChange('');
|
|
89
|
+
onClear();
|
|
90
|
+
}, [clearBlurs, onChange, onClear, textIsValid]);
|
|
91
|
+
// memo handling value updates based on input
|
|
92
|
+
const handleValueChange = useCallback((newValue) => {
|
|
93
|
+
setText(newValue);
|
|
94
|
+
onChange(newValue);
|
|
95
|
+
if (!valid)
|
|
96
|
+
textIsValid(text);
|
|
97
|
+
}, [onChange, textIsValid, text, valid]);
|
|
98
|
+
// memo blur handler
|
|
99
|
+
const handleBlur = useCallback(() => {
|
|
100
|
+
textIsValid(text);
|
|
101
|
+
setIsFocused(false);
|
|
102
|
+
onBlur(text);
|
|
103
|
+
}, [text, onBlur, textIsValid]);
|
|
104
|
+
// memo key stroke handling
|
|
105
|
+
const handleKeyDown = useCallback((e) => {
|
|
106
|
+
var _a;
|
|
107
|
+
if (e.key === 'Enter') {
|
|
108
|
+
handleBlur();
|
|
109
|
+
onSubmit(text);
|
|
110
|
+
(_a = input.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
111
|
+
}
|
|
112
|
+
if (disabled) {
|
|
113
|
+
e.preventDefault();
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
onKeydown(e.key, e);
|
|
117
|
+
}, [text, disabled, onSubmit, onKeydown, handleBlur]);
|
|
118
|
+
// memo handle focus
|
|
119
|
+
const handleFocus = useCallback(() => {
|
|
120
|
+
setIsFocused(true);
|
|
121
|
+
onFocus(text);
|
|
122
|
+
}, [text, onFocus]);
|
|
123
|
+
// memo toggle show (for passwords)
|
|
124
|
+
const toggleShow = useCallback(() => {
|
|
125
|
+
setShow((prev) => !prev);
|
|
126
|
+
}, []);
|
|
127
|
+
// memo icon style
|
|
128
|
+
const iconContainerStyle = useMemo(() => iconLeft ? { width: iconLeft.size, height: iconLeft.size } : undefined, [iconLeft]);
|
|
129
|
+
// memo icon color
|
|
130
|
+
const iconStrokeColor = useMemo(() => (iconLeft === null || iconLeft === void 0 ? void 0 : iconLeft.color)
|
|
131
|
+
? iconLeft.color
|
|
132
|
+
: theme.current.colors['core-icon-secondary'], [iconLeft, theme]);
|
|
133
|
+
// memo show clear button
|
|
134
|
+
const clearButtonStyle = useMemo(() => clearButton
|
|
135
|
+
? { width: clearButton.size, height: clearButton.size }
|
|
136
|
+
: undefined, [clearButton]);
|
|
137
|
+
// process style values that are string, number or undefined
|
|
138
|
+
const setStyleValue = useCallback((value) => {
|
|
139
|
+
if (value === undefined)
|
|
140
|
+
return 'unset';
|
|
141
|
+
if (typeof value === 'string')
|
|
142
|
+
return value;
|
|
143
|
+
return `${value}px`;
|
|
144
|
+
}, []);
|
|
145
|
+
// memo background color
|
|
146
|
+
const setBackgroundColor = useMemo(() => {
|
|
147
|
+
var _a, _b;
|
|
148
|
+
if (inline)
|
|
149
|
+
return 'unset';
|
|
150
|
+
if (isFocused)
|
|
151
|
+
return (_a = backgroundColor.focused) !== null && _a !== void 0 ? _a : 'transparent';
|
|
152
|
+
return (_b = backgroundColor.blurred) !== null && _b !== void 0 ? _b : 'transparent';
|
|
153
|
+
}, [inline, isFocused, backgroundColor]);
|
|
154
|
+
// memo border color
|
|
155
|
+
const setBorderColor = useMemo(() => {
|
|
156
|
+
var _a, _b, _c, _d, _e;
|
|
157
|
+
if (borderType === 'none')
|
|
158
|
+
return 'transparent';
|
|
159
|
+
if (validate && !valid)
|
|
160
|
+
return (_b = (_a = borderColor.error) !== null && _a !== void 0 ? _a : borderColor.blurred) !== null && _b !== void 0 ? _b : 'transparent';
|
|
161
|
+
if (isFocused)
|
|
162
|
+
return (_d = (_c = borderColor.focused) !== null && _c !== void 0 ? _c : borderColor.blurred) !== null && _d !== void 0 ? _d : 'transparent';
|
|
163
|
+
return (_e = borderColor.blurred) !== null && _e !== void 0 ? _e : 'transparent';
|
|
164
|
+
}, [borderType, valid, isFocused, borderColor, validate]);
|
|
165
|
+
// memo box shadow (border style)
|
|
166
|
+
const setBoxShadow = useMemo(() => {
|
|
167
|
+
if (borderType === 'none')
|
|
168
|
+
return 'unset';
|
|
169
|
+
if (borderType === 'underline')
|
|
170
|
+
return `0 1px 0 0 ${setBorderColor}`;
|
|
171
|
+
return `0 0 0 1px ${setBorderColor}`;
|
|
172
|
+
}, [borderType, setBorderColor]);
|
|
173
|
+
// memo text color
|
|
174
|
+
const textColor = useMemo(() => {
|
|
175
|
+
var _a, _b, _c;
|
|
176
|
+
if (validate && !valid)
|
|
177
|
+
return (_a = color.error) !== null && _a !== void 0 ? _a : 'var(--core-text-primary)';
|
|
178
|
+
if (isFocused)
|
|
179
|
+
return (_b = color.focused) !== null && _b !== void 0 ? _b : 'var(--core-text-primary)';
|
|
180
|
+
return (_c = color.blurred) !== null && _c !== void 0 ? _c : 'var(--core-text-primary)';
|
|
181
|
+
}, [isFocused, valid, color, validate]);
|
|
182
|
+
// memo text align
|
|
183
|
+
const setTextAlign = useMemo(() => {
|
|
184
|
+
return textAlign !== null && textAlign !== void 0 ? textAlign : 'left';
|
|
185
|
+
}, [textAlign]);
|
|
186
|
+
// memo opacity password show / hide
|
|
187
|
+
const setShowOpacity = useMemo(() => {
|
|
188
|
+
if (inputType !== 'password')
|
|
189
|
+
return '0';
|
|
190
|
+
if (isFocused)
|
|
191
|
+
return '1';
|
|
192
|
+
return '0.5';
|
|
193
|
+
}, [inputType, isFocused]);
|
|
194
|
+
// memo css vars
|
|
195
|
+
const cssVars = useMemo(() => {
|
|
196
|
+
var _a, _b;
|
|
197
|
+
return {
|
|
198
|
+
'--tf-width': setStyleValue(size.width),
|
|
199
|
+
'--tf-height': setStyleValue(size.height),
|
|
200
|
+
'--tf-padding': setStyleValue(padding),
|
|
201
|
+
'--tf-padding-label-left': label === '' ? 'unset' : '0',
|
|
202
|
+
'--tf-border-radius': setStyleValue(borderRadius),
|
|
203
|
+
'--tf-bg-color': setBackgroundColor,
|
|
204
|
+
'--tf-box-shadow': setBoxShadow,
|
|
205
|
+
'--tf-color': textColor,
|
|
206
|
+
'--tf-label-color': (_a = color.label) !== null && _a !== void 0 ? _a : 'var(--core-text-disabled)',
|
|
207
|
+
'--tf-text-align': setTextAlign,
|
|
208
|
+
'--tf-show-opacity': setShowOpacity,
|
|
209
|
+
'--tf-placeholder-color': (_b = color.placeholder) !== null && _b !== void 0 ? _b : 'var(--core-text-disabled)',
|
|
210
|
+
};
|
|
211
|
+
}, [
|
|
212
|
+
size,
|
|
213
|
+
padding,
|
|
214
|
+
label,
|
|
215
|
+
borderRadius,
|
|
216
|
+
setStyleValue,
|
|
217
|
+
setBackgroundColor,
|
|
218
|
+
setBoxShadow,
|
|
219
|
+
textColor,
|
|
220
|
+
setTextAlign,
|
|
221
|
+
setShowOpacity,
|
|
222
|
+
color,
|
|
223
|
+
]);
|
|
224
|
+
return (jsxs("div", Object.assign({ id: divId, className: `${css.wrapper}${divClass}`, style: Object.assign(Object.assign({}, divStyle), cssVars) }, rest, { children: [label && (jsx("div", { className: `${css.label} ${css[labelSize]}`, children: label })), jsxs("div", { className: css.container, children: [iconLeft && (jsx("div", { style: iconContainerStyle, children: jsx(Icon, { name: iconLeft.name, size: iconLeft.size, strokeColor: iconStrokeColor }) })), jsx("input", { className: `${css.input} ${css[textSize]}`, ref: input, type: inputType === 'password' && show ? 'text' : inputType, name: name, "aria-label": name, autoCapitalize: 'none', autoCorrect: 'off', autoComplete: 'off', value: text, onChange: (e) => handleValueChange(e.target.value), onKeyDown: handleKeyDown, onPaste: onPaste, placeholder: placeholder, onFocus: handleFocus, onBlur: handleBlur, onMouseDown: (e) => e.stopPropagation(), disabled: !editable, maxLength: maxLength }), jsx(AnimatePresence, { initial: false, children: isFocused && clearButton && text !== '' && (jsx(motion.div, { className: css.clearButton, style: clearButtonStyle, variants: MOTION_CONFIG.variants, initial: 'initial', animate: 'animate', exit: 'exit', transition: MOTION_CONFIG.transition, onClick: handleClearTextField, children: jsx(Icon, { name: 'x', size: clearButton.size, strokeColor: theme.current.colors['core-icon-secondary'] }) })) }), jsx(AnimatePresence, { initial: false, children: actionButton && (jsx(motion.div, { variants: MOTION_CONFIG.variants, initial: 'initial', animate: 'animate', exit: 'exit', transition: MOTION_CONFIG.transition, children: jsx(UIButton, { label: 'Translate', variant: 'text', size: 'text', state: text === '' ? 'disabled' : 'normal', labelColor: theme.current.colors['core-button-primary'], onClick: onAction }) })) }), inputType === 'password' && !noShow && (jsx("div", { className: css.showPassword, children: jsx(IconButton, { icon: 'view', toggleIcon: true, toggle: false, isToggled: show, iconSize: 18, frameSize: 18, onClick: toggleShow, tooltip: 'Show / Hide', disabled: false }) }))] })] })));
|
|
225
|
+
}, (prevProps, nextProps) => {
|
|
226
|
+
// Custom comparison for expensive props
|
|
227
|
+
return (prevProps.value === nextProps.value &&
|
|
228
|
+
prevProps.borderType === nextProps.borderType &&
|
|
229
|
+
prevProps.borderRadius === nextProps.borderRadius &&
|
|
230
|
+
prevProps.borderColor === nextProps.borderColor &&
|
|
231
|
+
prevProps.labelSize === nextProps.labelSize &&
|
|
232
|
+
prevProps.focused === nextProps.focused &&
|
|
233
|
+
prevProps.isValid === nextProps.isValid &&
|
|
234
|
+
prevProps.validate === nextProps.validate &&
|
|
235
|
+
prevProps.disabled === nextProps.disabled &&
|
|
236
|
+
prevProps.color === nextProps.color &&
|
|
237
|
+
prevProps.label === nextProps.label &&
|
|
238
|
+
prevProps.inputType === nextProps.inputType &&
|
|
239
|
+
prevProps.textSize === nextProps.textSize &&
|
|
240
|
+
prevProps.padding === nextProps.padding &&
|
|
241
|
+
prevProps.textAlign === nextProps.textAlign &&
|
|
242
|
+
prevProps.placeholder === nextProps.placeholder);
|
|
243
|
+
});
|
|
244
|
+
TextField.displayName = 'TextField';
|
|
245
|
+
|
|
246
|
+
export { TextField as T };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { _ as __rest } from './tslib.es6-0pkUdtrF.js';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { motion } from 'motion/react';
|
|
4
|
+
import React, { useState, useRef, useEffect, useMemo } from 'react';
|
|
5
|
+
import { f as filterClasses } from './utils-BRZK2Drn.js';
|
|
6
|
+
import { s as styleInject } from './style-inject.es-tgCJW-Cu.js';
|
|
7
|
+
|
|
8
|
+
var css_248z = ".flexBox-module_row__PWxbe {\n\tdisplay: flex;\n\tjustify-content: center;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_rowBetween__27lKK {\n\tdisplay: flex;\n\tjustify-content: space-between;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_rowStart__nJZnW {\n\tdisplay: flex;\n\tjustify-content: flex-start;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_rowEnd__dHcOU {\n\tdisplay: flex;\n\tjustify-content: flex-end;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_column__MP2Xd {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: center;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnStart__Kg8cV {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: flex-start;\n\talign-items: flex-start;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnStartCenter__zcmtk {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: flex-start;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnBetween__157yI {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: space-between;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnEnd__u2nwI {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: flex-end;\n\talign-items: flex-end;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.type-module_body-xs-regular__QWEzl {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-regular);\n\tfont-size: var(--font-size-xs);\n\tline-height: 133.33%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_body-xs-medium__FxEAv {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-medium);\n\tfont-size: var(--font-size-xs);\n\tline-height: 133.33%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_body-xs-bold__rf7AV {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-bold);\n\tfont-size: var(--font-size-xs);\n\tline-height: 133.33%;\n\ttext-decoration: none;\n\tletter-spacing: 0.25px;\n}.type-module_body-s-regular__8-FO- {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-regular);\n\tfont-size: var(--font-size-s);\n\tline-height: 142.86%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_body-s-medium__qyYq- {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-medium);\n\tfont-size: var(--font-size-s);\n\tline-height: 142.86%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_body-s-bold__7GQ5Z {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-bold);\n\tfont-size: var(--font-size-s);\n\tline-height: 142.86%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_body-m-regular__Qtp5G {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-regular);\n\tfont-size: var(--font-size-m);\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_body-m-medium__Ieh9K {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-medium);\n\tfont-size: var(--font-size-m);\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_body-m-bold__0lZ3I {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-bold);\n\tfont-size: var(--font-size-m);\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_body-l-regular__Ar4d3 {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-regular);\n\tfont-size: var(--font-size-l);\n\tline-height: 162.5%;\n\ttext-decoration: none;\n\tletter-spacing: 0.1px;\n}.type-module_body-l-medium__6tV1n {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-medium);\n\tfont-size: var(--font-size-l);\n\tline-height: 162.5%;\n\ttext-decoration: none;\n\tletter-spacing: 0.1px;\n}.type-module_body-l-bold__I8Q1v {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-bold);\n\tfont-size: var(--font-size-l);\n\tline-height: 162.5%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_heading-s-bold__QFgN8 {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 650;\n\tfont-size: 20px;\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-s-medium__jGIb2 {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 560;\n\tfont-size: 20px;\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-m-bold__tdBSi {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 650;\n\tfont-size: 24px;\n\tline-height: 116.67%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-m-medium__-7Uyu {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 560;\n\tfont-size: 24px;\n\tline-height: 116.67%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-l-medium__8hGYF {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 560;\n\tfont-size: 28px;\n\tline-height: 128.57%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-l-bold__Cryjg {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 650;\n\tfont-size: 28px;\n\tline-height: 128.57%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}\n\n.Tip-module_wrapper__5Oi05 {\n\tpadding: var(--tooltip-padding) !important;\n\tposition: fixed;\n\tborder: var(--tooltip-border);\n\tborder-radius: var(--tooltip-border-radius);\n\tbackground: var(--tooltip-background);\n\tz-index: 10;\n}\n\n.Tip-module_s__URuK6 {\n}\n\n.Tip-module_m__A1uk0 {\n}\n.Tip-module_l__kNOKI {\n}\n";
|
|
9
|
+
var css = {"wrapper":"Tip-module_wrapper__5Oi05 flexBox-module_rowStart__nJZnW","s":"Tip-module_s__URuK6 type-module_body-s-regular__8-FO-","m":"Tip-module_m__A1uk0 type-module_body-m-regular__Qtp5G","l":"Tip-module_l__kNOKI type-module_body-l-regular__Ar4d3"};
|
|
10
|
+
styleInject(css_248z);
|
|
11
|
+
|
|
12
|
+
const tipBasePos = { left: 0, top: 0 };
|
|
13
|
+
|
|
14
|
+
const TipBase = React.forwardRef((props, ref) => {
|
|
15
|
+
var _a;
|
|
16
|
+
const { tip, size = 's', bgColor, color, border = true, borderColor, padding, radius, coords, showDelay = 500, hideDelay = 2500 } = props, divAttributes = __rest(props, ["tip", "size", "bgColor", "color", "border", "borderColor", "padding", "radius", "coords", "showDelay", "hideDelay"]);
|
|
17
|
+
// div attributes to add
|
|
18
|
+
const { id: divId, className, style } = divAttributes, rest = __rest(divAttributes, ["id", "className", "style"]);
|
|
19
|
+
const divStyle = style !== null && style !== void 0 ? style : {};
|
|
20
|
+
const divClass = className ? `${className}` : '';
|
|
21
|
+
// set tip position and display timer
|
|
22
|
+
// need the animate set only after the ready state is processed
|
|
23
|
+
const [pos, setPos] = useState(tipBasePos);
|
|
24
|
+
const [ready, setReady] = useState(false);
|
|
25
|
+
const [animate, setAnimate] = useState(false);
|
|
26
|
+
const timer = useRef(null);
|
|
27
|
+
// update position with delay and then auto remove
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (timer.current)
|
|
30
|
+
clearTimeout(timer.current);
|
|
31
|
+
const { x, y } = coords !== null && coords !== void 0 ? coords : { x: 0, y: 0 };
|
|
32
|
+
const showTip = x > 0 && y > 0;
|
|
33
|
+
if (showTip) {
|
|
34
|
+
timer.current = setTimeout(() => {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
setPos({ left: (_a = coords === null || coords === void 0 ? void 0 : coords.x) !== null && _a !== void 0 ? _a : 0, top: (_b = coords === null || coords === void 0 ? void 0 : coords.y) !== null && _b !== void 0 ? _b : 0 });
|
|
37
|
+
setReady(true);
|
|
38
|
+
if (timer.current)
|
|
39
|
+
clearTimeout(timer.current);
|
|
40
|
+
timer.current = setTimeout(() => {
|
|
41
|
+
setReady(false);
|
|
42
|
+
setPos({ left: 0, top: 0 });
|
|
43
|
+
}, hideDelay);
|
|
44
|
+
}, showDelay);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
setReady(false);
|
|
48
|
+
setPos({ left: 0, top: 0 });
|
|
49
|
+
}
|
|
50
|
+
// clean up timers
|
|
51
|
+
return () => {
|
|
52
|
+
if (timer.current)
|
|
53
|
+
clearTimeout(timer.current);
|
|
54
|
+
};
|
|
55
|
+
}, [coords, showDelay, hideDelay]);
|
|
56
|
+
// when ready, visibility has taken effect and can now be animated
|
|
57
|
+
useEffect(() => setAnimate(ready), [ready]);
|
|
58
|
+
// memo css vars
|
|
59
|
+
const cssVars = useMemo(() => {
|
|
60
|
+
return {
|
|
61
|
+
'--tooltip-padding': padding !== null && padding !== void 0 ? padding : '3px 6px',
|
|
62
|
+
'--tooltip-background': bgColor !== null && bgColor !== void 0 ? bgColor : 'var(--core-surface-secondary)',
|
|
63
|
+
'--tooltip-color': color !== null && color !== void 0 ? color : 'var(--core-text-primary)',
|
|
64
|
+
'--tooltip-border': border
|
|
65
|
+
? `1px solid ${borderColor !== null && borderColor !== void 0 ? borderColor : 'var(--core-outline-primary)'}`
|
|
66
|
+
: 'unset',
|
|
67
|
+
'--tooltip-border-radius': radius !== null && radius !== void 0 ? radius : '4px',
|
|
68
|
+
};
|
|
69
|
+
}, [padding, bgColor, color, border, borderColor, radius]);
|
|
70
|
+
// memo coords style
|
|
71
|
+
const coordStyle = useMemo(() => {
|
|
72
|
+
const { left, top } = pos;
|
|
73
|
+
return {
|
|
74
|
+
left: `${left !== null && left !== void 0 ? left : 0}px`,
|
|
75
|
+
top: `${top !== null && top !== void 0 ? top : 0}px`,
|
|
76
|
+
};
|
|
77
|
+
}, [pos]);
|
|
78
|
+
// memo class names
|
|
79
|
+
const classNames = useMemo(() => {
|
|
80
|
+
return filterClasses([css.wrapper, css[size], divClass]);
|
|
81
|
+
}, [size, divClass]);
|
|
82
|
+
return (jsx(motion.div, Object.assign({ ref: ref, id: divId, className: classNames, onKeyDown: () => null, style: Object.assign(Object.assign(Object.assign(Object.assign({}, divStyle), cssVars), coordStyle), { visibility: ready ? 'visible' : 'hidden' }), initial: { opacity: 0 }, animate: animate
|
|
83
|
+
? { opacity: 1, transition: { ease: 'easeInOut', duration: 0.25 } }
|
|
84
|
+
: undefined, exit: { opacity: 0, transition: { duration: 0 } } }, rest, { children: (_a = tip === null || tip === void 0 ? void 0 : tip.payload) === null || _a === void 0 ? void 0 : _a.label })));
|
|
85
|
+
});
|
|
86
|
+
TipBase.displayName = 'Tip';
|
|
87
|
+
const Tip = React.memo(TipBase);
|
|
88
|
+
|
|
89
|
+
export { Tip as T };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { _ as __rest } from './tslib.es6-0pkUdtrF.js';
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { AnimatePresence, motion } from 'motion/react';
|
|
4
|
+
import React, { useState, useRef, useEffect, useMemo, useCallback } from 'react';
|
|
5
|
+
import { useTheme } from '../hooks/useTheme.js';
|
|
6
|
+
import '../theme/colors.js';
|
|
7
|
+
import '../hooks/useWindow.js';
|
|
8
|
+
import { s as setStyle, f as filterClasses, a as accessibleKeyDown } from './utils-BRZK2Drn.js';
|
|
9
|
+
import { I as Icon } from './_types-BaYeLEWK.js';
|
|
10
|
+
import { s as styleInject } from './style-inject.es-tgCJW-Cu.js';
|
|
11
|
+
|
|
12
|
+
var css_248z = ".flexBox-module_row__PWxbe {\n\tdisplay: flex;\n\tjustify-content: center;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_rowBetween__27lKK {\n\tdisplay: flex;\n\tjustify-content: space-between;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_rowStart__nJZnW {\n\tdisplay: flex;\n\tjustify-content: flex-start;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_rowEnd__dHcOU {\n\tdisplay: flex;\n\tjustify-content: flex-end;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_column__MP2Xd {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: center;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnStart__Kg8cV {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: flex-start;\n\talign-items: flex-start;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnStartCenter__zcmtk {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: flex-start;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnBetween__157yI {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: space-between;\n\talign-items: center;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.flexBox-module_columnEnd__u2nwI {\n\tdisplay: flex;\n\tflex-direction: column;\n\tjustify-content: flex-end;\n\talign-items: flex-end;\n\tbox-sizing: border-box;\n\tpadding: 0;\n\tmargin: 0;\n}.type-module_body-xs-regular__QWEzl {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-regular);\n\tfont-size: var(--font-size-xs);\n\tline-height: 133.33%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_body-xs-medium__FxEAv {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-medium);\n\tfont-size: var(--font-size-xs);\n\tline-height: 133.33%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_body-xs-bold__rf7AV {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-bold);\n\tfont-size: var(--font-size-xs);\n\tline-height: 133.33%;\n\ttext-decoration: none;\n\tletter-spacing: 0.25px;\n}.type-module_body-s-regular__8-FO- {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-regular);\n\tfont-size: var(--font-size-s);\n\tline-height: 142.86%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_body-s-medium__qyYq- {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-medium);\n\tfont-size: var(--font-size-s);\n\tline-height: 142.86%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_body-s-bold__7GQ5Z {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-bold);\n\tfont-size: var(--font-size-s);\n\tline-height: 142.86%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_body-m-regular__Qtp5G {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-regular);\n\tfont-size: var(--font-size-m);\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_body-m-medium__Ieh9K {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-medium);\n\tfont-size: var(--font-size-m);\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_body-m-bold__0lZ3I {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-bold);\n\tfont-size: var(--font-size-m);\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_body-l-regular__Ar4d3 {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-regular);\n\tfont-size: var(--font-size-l);\n\tline-height: 162.5%;\n\ttext-decoration: none;\n\tletter-spacing: 0.1px;\n}.type-module_body-l-medium__6tV1n {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-medium);\n\tfont-size: var(--font-size-l);\n\tline-height: 162.5%;\n\ttext-decoration: none;\n\tletter-spacing: 0.1px;\n}.type-module_body-l-bold__I8Q1v {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: var(--font-weight-bold);\n\tfont-size: var(--font-size-l);\n\tline-height: 162.5%;\n\ttext-decoration: none;\n\tletter-spacing: 0.15px;\n}.type-module_heading-s-bold__QFgN8 {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 650;\n\tfont-size: 20px;\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-s-medium__jGIb2 {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 560;\n\tfont-size: 20px;\n\tline-height: 140%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-m-bold__tdBSi {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 650;\n\tfont-size: 24px;\n\tline-height: 116.67%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-m-medium__-7Uyu {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 560;\n\tfont-size: 24px;\n\tline-height: 116.67%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-l-medium__8hGYF {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 560;\n\tfont-size: 28px;\n\tline-height: 128.57%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}.type-module_heading-l-bold__Cryjg {\n\tfont-family: var(--font-family), sans-serif;\n\tfont-weight: 650;\n\tfont-size: 28px;\n\tline-height: 128.57%;\n\ttext-decoration: none;\n\tletter-spacing: 0.2px;\n}\n\n.Toast-module_wrapper__WglRd {\n\tpadding: var(--toast-padding) !important;\n\tcolor: var(--toast-color);\n\tposition: fixed;\n\tborder: var(--toast-border);\n\tborder-radius: var(--toast-border-radius);\n\tbackground: var(--toast-background);\n\tz-index: 10;\n\tgap: 16px;\n\tbox-shadow: var(--surface-shadow-soft);\n\tleft: 50%;\n\ttransform: translateX(-50%);\n}\n\n.Toast-module_close__fIkbN {\n\tmin-height: 20px;\n\tmax-height: 20px;\n\tmin-width: 20px;\n\tmax-width: 20px;\n}\n\n.Toast-module_s__eexrd {\n}\n\n.Toast-module_m__eByaG {\n}\n.Toast-module_l__t7hfh {\n}\n";
|
|
13
|
+
var css = {"wrapper":"Toast-module_wrapper__WglRd flexBox-module_rowBetween__27lKK","close":"Toast-module_close__fIkbN flexBox-module_row__PWxbe","s":"Toast-module_s__eexrd type-module_body-s-regular__8-FO-","m":"Toast-module_m__eByaG type-module_body-m-regular__Qtp5G","l":"Toast-module_l__t7hfh type-module_body-l-regular__Ar4d3"};
|
|
14
|
+
styleInject(css_248z);
|
|
15
|
+
|
|
16
|
+
var ToastType;
|
|
17
|
+
(function (ToastType) {
|
|
18
|
+
ToastType["Success"] = "success";
|
|
19
|
+
ToastType["Error"] = "error";
|
|
20
|
+
ToastType["Warning"] = "warning";
|
|
21
|
+
ToastType["Info"] = "info";
|
|
22
|
+
})(ToastType || (ToastType = {}));
|
|
23
|
+
|
|
24
|
+
const ToastBase = React.forwardRef((props, ref) => {
|
|
25
|
+
const { message = null, size = 'm', border = true, padding, radius = 8, showDelay = 0, duration = 5000, position = 'bottom', offset = 24, close = true, type = ToastType.Info, didHide = () => null } = props, divAttributes = __rest(props, ["message", "size", "border", "padding", "radius", "showDelay", "duration", "position", "offset", "close", "type", "didHide"]);
|
|
26
|
+
const theme = useTheme();
|
|
27
|
+
// div attributes to add
|
|
28
|
+
const { id: divId, className, style } = divAttributes, rest = __rest(divAttributes, ["id", "className", "style"]);
|
|
29
|
+
const divStyle = style !== null && style !== void 0 ? style : {};
|
|
30
|
+
const divClass = className ? `${className}` : '';
|
|
31
|
+
// need the animate set only after the ready state is processed
|
|
32
|
+
const [ready, setReady] = useState(false);
|
|
33
|
+
const [content, setContent] = useState(null);
|
|
34
|
+
const timer = useRef(null);
|
|
35
|
+
// update show and animation
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (timer.current)
|
|
38
|
+
clearTimeout(timer.current);
|
|
39
|
+
const show = message && message.length > 0;
|
|
40
|
+
if (show) {
|
|
41
|
+
timer.current = setTimeout(() => {
|
|
42
|
+
setContent(message);
|
|
43
|
+
if (timer.current)
|
|
44
|
+
clearTimeout(timer.current);
|
|
45
|
+
timer.current = setTimeout(() => {
|
|
46
|
+
setReady(false);
|
|
47
|
+
}, duration);
|
|
48
|
+
}, showDelay);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
setContent(null);
|
|
52
|
+
}
|
|
53
|
+
// clean up timers
|
|
54
|
+
return () => {
|
|
55
|
+
if (timer.current)
|
|
56
|
+
clearTimeout(timer.current);
|
|
57
|
+
};
|
|
58
|
+
}, [message, showDelay, duration]);
|
|
59
|
+
// ready to animate in/out
|
|
60
|
+
useEffect(() => setReady(content !== null), [content]);
|
|
61
|
+
// set the default padding accommodating the close icon fix
|
|
62
|
+
const defaultPadding = useMemo(() => {
|
|
63
|
+
return close ? '10px 12px 10px 16px' : '10px 16px';
|
|
64
|
+
}, [close]);
|
|
65
|
+
const colorScheme = useMemo(() => {
|
|
66
|
+
switch (type) {
|
|
67
|
+
case 'success':
|
|
68
|
+
return {
|
|
69
|
+
border: 'var(--array-land-label)',
|
|
70
|
+
bg: 'var(--array-land)',
|
|
71
|
+
text: 'var(--array-land-label)',
|
|
72
|
+
};
|
|
73
|
+
case 'warning':
|
|
74
|
+
return {
|
|
75
|
+
border: 'var(--array-orange-label)',
|
|
76
|
+
bg: 'var(--array-orange)',
|
|
77
|
+
text: 'var(--array-orange-label)',
|
|
78
|
+
};
|
|
79
|
+
case 'error':
|
|
80
|
+
return {
|
|
81
|
+
border: 'var(--feedback-warning)',
|
|
82
|
+
bg: 'var(--array-magenta)',
|
|
83
|
+
text: 'var(--feedback-warning)',
|
|
84
|
+
};
|
|
85
|
+
default:
|
|
86
|
+
return {
|
|
87
|
+
border: 'var(--core-outline-primary)',
|
|
88
|
+
bg: 'var(--core-surface-secondary)',
|
|
89
|
+
text: 'var(--core-text-primary)',
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}, [type]);
|
|
93
|
+
// memo css vars
|
|
94
|
+
const cssVars = useMemo(() => {
|
|
95
|
+
return {
|
|
96
|
+
'--toast-padding': setStyle(padding, defaultPadding),
|
|
97
|
+
'--toast-background': colorScheme.bg,
|
|
98
|
+
'--toast-color': colorScheme.text,
|
|
99
|
+
'--toast-border': border ? `1px solid ${colorScheme.border}` : 'unset',
|
|
100
|
+
'--toast-border-radius': setStyle(radius, 4),
|
|
101
|
+
};
|
|
102
|
+
}, [padding, border, colorScheme, radius, defaultPadding]);
|
|
103
|
+
const variants = useMemo(() => {
|
|
104
|
+
const positionShow = position === 'bottom' ? { bottom: offset } : { top: offset };
|
|
105
|
+
const positionHide = position === 'bottom' ? { bottom: -offset } : { top: -offset };
|
|
106
|
+
const transition = { ease: 'easeInOut', duration: 0.25 };
|
|
107
|
+
return {
|
|
108
|
+
initial: Object.assign({ opacity: 0 }, positionHide),
|
|
109
|
+
animate: Object.assign(Object.assign({ opacity: 1 }, positionShow), { transition }),
|
|
110
|
+
exit: Object.assign(Object.assign({ opacity: 0 }, positionHide), { transition }),
|
|
111
|
+
};
|
|
112
|
+
}, [position, offset]);
|
|
113
|
+
// memo class names
|
|
114
|
+
const classNames = useMemo(() => {
|
|
115
|
+
return filterClasses([css.wrapper, css[size], divClass]);
|
|
116
|
+
}, [size, divClass]);
|
|
117
|
+
// hide on close
|
|
118
|
+
const handleClose = useCallback(() => {
|
|
119
|
+
setReady(false);
|
|
120
|
+
}, []);
|
|
121
|
+
// prevent hide on hover / focus
|
|
122
|
+
const handleMouseOver = useCallback(() => {
|
|
123
|
+
if (timer.current)
|
|
124
|
+
clearTimeout(timer.current);
|
|
125
|
+
}, []);
|
|
126
|
+
// rest hide on mouse out / blur
|
|
127
|
+
const handleMouseOut = useCallback(() => {
|
|
128
|
+
if (timer.current)
|
|
129
|
+
clearTimeout(timer.current);
|
|
130
|
+
timer.current = setTimeout(() => {
|
|
131
|
+
setContent(null);
|
|
132
|
+
}, duration);
|
|
133
|
+
}, [duration]);
|
|
134
|
+
return (jsx(AnimatePresence, { onExitComplete: () => didHide(), initial: false, children: ready && (jsxs(motion.div, Object.assign({ ref: ref, id: divId, className: classNames }, rest, { onMouseEnter: handleMouseOver, onMouseLeave: handleMouseOut, onFocus: handleMouseOver, onBlur: handleMouseOut, style: Object.assign(Object.assign(Object.assign({}, divStyle), cssVars), { visibility: ready ? 'visible' : 'hidden' }), variants: variants, initial: 'initial', animate: 'animate', exit: 'exit', children: [jsx("div", { role: 'status', "aria-live": 'polite', className: css.message, children: content }), close && (jsx("div", { className: css.close, tabIndex: 0, role: 'button', "aria-label": 'dismiss message', onKeyDown: (e) => accessibleKeyDown(e, handleClose), onClick: handleClose, children: jsx(Icon, { name: 'x', size: 20, strokeColor: theme.current.colors['core-icon-primary'] }) }))] }))) }));
|
|
135
|
+
});
|
|
136
|
+
ToastBase.displayName = 'Toast';
|
|
137
|
+
const Toast = React.memo(ToastBase);
|
|
138
|
+
|
|
139
|
+
export { Toast as T, ToastType as a };
|