@hi-ui/tabs 4.0.0-beta.2 → 4.0.0-beta.20
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/lib/cjs/TabInk.js +32 -27
- package/lib/cjs/TabItem.js +5 -6
- package/lib/cjs/TabList.js +178 -129
- package/lib/cjs/TabPane.js +16 -8
- package/lib/cjs/Tabs.js +9 -11
- package/lib/cjs/hooks/index.js +63 -0
- package/lib/cjs/index.js +6 -4
- package/lib/cjs/styles/index.scss.js +2 -3
- package/lib/cjs/utils/index.js +32 -0
- package/lib/esm/TabInk.js +31 -26
- package/lib/esm/TabItem.js +0 -1
- package/lib/esm/TabList.js +171 -126
- package/lib/esm/TabPane.js +13 -8
- package/lib/esm/Tabs.js +4 -6
- package/lib/esm/hooks/index.js +54 -0
- package/lib/esm/index.js +7 -2
- package/lib/esm/styles/index.scss.js +3 -5
- package/lib/esm/utils/index.js +26 -0
- package/lib/types/TabInk.d.ts +6 -6
- package/lib/types/TabItem.d.ts +2 -2
- package/lib/types/TabList.d.ts +35 -4
- package/lib/types/TabPane.d.ts +20 -3
- package/lib/types/Tabs.d.ts +14 -17
- package/lib/types/hooks/index.d.ts +11 -0
- package/lib/types/index.d.ts +5 -1
- package/lib/types/utils/index.d.ts +3 -0
- package/package.json +13 -9
- package/lib/cjs/TabInk.js.map +0 -1
- package/lib/cjs/TabItem.js.map +0 -1
- package/lib/cjs/TabList.js.map +0 -1
- package/lib/cjs/TabPane.js.map +0 -1
- package/lib/cjs/Tabs.js.map +0 -1
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/styles/index.scss.js.map +0 -1
- package/lib/esm/TabInk.js.map +0 -1
- package/lib/esm/TabItem.js.map +0 -1
- package/lib/esm/TabList.js.map +0 -1
- package/lib/esm/TabPane.js.map +0 -1
- package/lib/esm/Tabs.js.map +0 -1
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/styles/index.scss.js.map +0 -1
package/lib/cjs/index.js
CHANGED
|
@@ -15,14 +15,16 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
15
15
|
|
|
16
16
|
require('./styles/index.scss.js');
|
|
17
17
|
|
|
18
|
-
var Tabs = require('./Tabs.js');
|
|
18
|
+
var Tabs$1 = require('./Tabs.js');
|
|
19
19
|
|
|
20
20
|
var TabPane = require('./TabPane.js');
|
|
21
21
|
|
|
22
22
|
var TabList = require('./TabList.js');
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
var Tabs = Object.assign(Tabs$1.Tabs, {
|
|
25
|
+
Pane: TabPane.TabPane
|
|
26
|
+
});
|
|
27
|
+
exports.Tabs = Tabs$1.Tabs;
|
|
26
28
|
exports.TabPane = TabPane.TabPane;
|
|
27
29
|
exports.TabList = TabList.TabList;
|
|
28
|
-
|
|
30
|
+
exports["default"] = Tabs;
|
|
@@ -12,11 +12,10 @@
|
|
|
12
12
|
Object.defineProperty(exports, '__esModule', {
|
|
13
13
|
value: true
|
|
14
14
|
});
|
|
15
|
-
var css_248z = "@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n@use 'sass:map';\n.hi-v4-tabs__add-btn.hi-v4-icon-button {\n font-size: 0.875rem;\n font-size: var(--hi-v4-text-size-normal, 0.875rem); }\n.hi-v4-tabs__up-btn.hi-v4-icon-button, .hi-v4-tabs__down-btn.hi-v4-icon-button, .hi-v4-tabs__left-btn.hi-v4-icon-button, .hi-v4-tabs__right-btn.hi-v4-icon-button {\n margin: 2px;\n margin: var(--hi-v4-spacing-1, 2px); }\n.hi-v4-tabs__close-btn {\n cursor: pointer;\n color: #929aa6;\n color: var(--hi-v4-color-gray-500, #929aa6);\n margin-left: 4px;\n margin-left: var(--hi-v4-spacing-2, 4px);\n -webkit-transition: color 0.3s;\n transition: color 0.3s; }\n.hi-v4-tabs__close-btn:hover {\n color: #237ffa;\n color: var(--hi-v4-color-brandblue-500, #237ffa); }\n.hi-v4-tabs--card .hi-v4-tabs__content {\n background-color: #fff;\n background-color: var(--hi-v4-color-static-white, #fff); }\n.hi-v4-tabs__list {\n position: relative;\n font-size: 0.875rem;\n font-size: var(--hi-v4-text-size-normal, 0.875rem);\n color: #929aa6;\n color: var(--hi-v4-color-gray-500, #929aa6);\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n overflow: hidden;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center; }\n.hi-v4-tabs__list--card .hi-v4-tabs__item {\n background-color: #ebedf0;\n background-color: var(--hi-v4-color-gray-200, #ebedf0);\n margin: 0;\n padding: 8px 20px;\n padding: var(--hi-v4-spacing-4, 8px) var(--hi-v4-spacing-10, 20px);\n border-radius: 4px 4px 0 0;\n border-radius: var(--hi-v4-border-radius-normal, 4px) var(--hi-v4-border-radius-normal, 4px) 0 0;\n -webkit-transition: all 0.3s;\n transition: all 0.3s; }\n.hi-v4-tabs__list--card .hi-v4-tabs__item--active {\n color: #237ffa;\n color: var(--hi-v4-color-brandblue-500, #237ffa);\n background-color: #fff;\n background-color: var(--hi-v4-color-static-white, #fff); }\n.hi-v4-tabs__list--button .hi-v4-tabs__item {\n margin: 4px 4px 4px 0;\n margin: var(--hi-v4-spacing-2, 4px) var(--hi-v4-spacing-2, 4px) var(--hi-v4-spacing-2, 4px) 0;\n padding: 4px 20px;\n padding: var(--hi-v4-spacing-2, 4px) var(--hi-v4-spacing-10, 20px);\n border-radius: 4px;\n border-radius: var(--hi-v4-border-radius-normal, 4px);\n -webkit-transition: all 0.3s;\n transition: all 0.3s; }\n.hi-v4-tabs__list--button .hi-v4-tabs__item:not(.hi-v4-tabs__item--active):hover {\n background-color: #ebedf0;\n background-color: var(--hi-v4-color-gray-200, #ebedf0);\n color: #929aa6;\n color: var(--hi-v4-color-gray-500, #929aa6); }\n.hi-v4-tabs__list--button .hi-v4-tabs__item--active {\n color: #237ffa;\n color: var(--hi-v4-color-brandblue-500, #237ffa);\n background-color: #e2f3fe;\n background-color: var(--hi-v4-color-brandblue-50, #e2f3fe); }\n.hi-v4-tabs__list--desc {\n padding: 0 20px;\n padding: 0 var(--hi-v4-spacing-10, 20px); }\n.hi-v4-tabs__list--desc .hi-v4-tabs-item__title {\n color: #1f2733;\n color: var(--hi-v4-color-gray-700, #1f2733); }\n.hi-v4-tabs__list--desc .hi-v4-tabs-item__desc {\n color: #929aa6;\n color: var(--hi-v4-color-gray-500, #929aa6);\n font-size: 0.75rem;\n font-size: var(--hi-v4-text-size-sm, 0.75rem);\n line-height: 1.25rem;\n line-height: var(--hi-v4-text-lineheight-sm, 1.25rem); }\n.hi-v4-tabs__list--desc .hi-v4-tabs__item {\n background: #f5f7fa;\n background: var(--hi-v4-color-gray-50, #f5f7fa);\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n margin: 20px 12px 20px 0;\n margin: var(--hi-v4-spacing-10, 20px) var(--hi-v4-spacing-6, 12px) var(--hi-v4-spacing-10, 20px) 0;\n padding: 16px 20px;\n padding: var(--hi-v4-spacing-8, 16px) var(--hi-v4-spacing-10, 20px);\n border-radius: 4px;\n border-radius: var(--hi-v4-border-radius-normal, 4px);\n -webkit-transition: all 0.3s;\n transition: all 0.3s; }\n.hi-v4-tabs__list--desc .hi-v4-tabs__item:not(.hi-v4-tabs__item--active):hover {\n background-color: #ebedf0;\n background-color: var(--hi-v4-color-gray-200, #ebedf0);\n color: #929aa6;\n color: var(--hi-v4-color-gray-500, #929aa6); }\n.hi-v4-tabs__list--desc .hi-v4-tabs__item--active {\n color: #237ffa;\n color: var(--hi-v4-color-brandblue-500, #237ffa);\n background-color: #e2f3fe;\n background-color: var(--hi-v4-color-brandblue-50, #e2f3fe); }\n.hi-v4-tabs__list--desc .hi-v4-tabs__item--active .hi-v4-tabs-item__title {\n color: #237ffa;\n color: var(--hi-v4-color-brandblue-500, #237ffa); }\n.hi-v4-tabs__list--desc .hi-v4-tabs__item--active .hi-v4-tabs-item__desc {\n color: #237ffa;\n color: var(--hi-v4-color-brandblue-500, #237ffa); }\n.hi-v4-tabs__list--inner {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-flex: 1;\n -ms-flex: 1 1;\n flex: 1 1;\n position: relative;\n overflow: hidden; }\n.hi-v4-tabs__list--scroll {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n position: relative;\n -webkit-transition: all 0.3s;\n transition: all 0.3s; }\n.hi-v4-tabs--vertical {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex; }\n.hi-v4-tabs--vertical .hi-v4-tabs__list {\n -ms-flex-negative: 0;\n flex-shrink: 0;\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column; }\n.hi-v4-tabs--vertical .hi-v4-tabs__list--card .hi-v4-tabs__item {\n margin: 0;\n padding: 8px 20px;\n padding: var(--hi-v4-spacing-4, 8px) var(--hi-v4-spacing-10, 20px);\n background-color: #ebedf0;\n background-color: var(--hi-v4-color-gray-200, #ebedf0);\n border-radius: 4px 0 0 4px;\n border-radius: var(--hi-v4-border-radius-normal, 4px) 0 0 var(--hi-v4-border-radius-normal, 4px);\n -webkit-transition: all 0.3s;\n transition: all 0.3s; }\n.hi-v4-tabs--vertical .hi-v4-tabs__list--card .hi-v4-tabs__item--active {\n color: #237ffa;\n color: var(--hi-v4-color-brandblue-500, #237ffa);\n background-color: #fff;\n background-color: var(--hi-v4-color-static-white, #fff); }\n.hi-v4-tabs--vertical .hi-v4-tabs__list--button .hi-v4-tabs__item {\n margin: 0 0 4px 0;\n margin: 0 0 var(--hi-v4-spacing-2, 4px) 0;\n padding: 4px 20px;\n padding: var(--hi-v4-spacing-2, 4px) var(--hi-v4-spacing-10, 20px);\n border-radius: 4px;\n border-radius: var(--hi-v4-border-radius-normal, 4px);\n -webkit-transition: all 0.3s;\n transition: all 0.3s; }\n.hi-v4-tabs--vertical .hi-v4-tabs__list--button .hi-v4-tabs__item:not(.hi-v4-tabs__item--active):hover {\n background-color: #ebedf0;\n background-color: var(--hi-v4-color-gray-200, #ebedf0);\n color: #929aa6;\n color: var(--hi-v4-color-gray-500, #929aa6); }\n.hi-v4-tabs--vertical .hi-v4-tabs__list--button .hi-v4-tabs__item--active {\n color: #237ffa;\n color: var(--hi-v4-color-brandblue-500, #237ffa);\n background-color: #e2f3fe;\n background-color: var(--hi-v4-color-brandblue-50, #e2f3fe); }\n.hi-v4-tabs--vertical .hi-v4-tabs__list--desc .hi-v4-tabs-item__title {\n color: #1f2733;\n color: var(--hi-v4-color-gray-700, #1f2733); }\n.hi-v4-tabs--vertical .hi-v4-tabs__list--desc .hi-v4-tabs-item__desc {\n color: #929aa6;\n color: var(--hi-v4-color-gray-500, #929aa6);\n font-size: 0.75rem;\n font-size: var(--hi-v4-text-size-sm, 0.75rem);\n line-height: 1.25rem;\n line-height: var(--hi-v4-text-lineheight-sm, 1.25rem); }\n.hi-v4-tabs--vertical .hi-v4-tabs__list--desc .hi-v4-tabs__item {\n display: -webkit-box;\n display: -ms-flexbox;\n display: flex;\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n -webkit-box-align: center;\n -ms-flex-align: center;\n align-items: center;\n margin: 0 0 12px 0;\n margin: 0 0 var(--hi-v4-spacing-6, 12px) 0;\n padding: 16px 20px;\n padding: var(--hi-v4-spacing-8, 16px) var(--hi-v4-spacing-10, 20px);\n border-radius: 4px;\n border-radius: var(--hi-v4-border-radius-normal, 4px);\n -webkit-transition: all 0.3s;\n transition: all 0.3s;\n background: #f5f7fa;\n background: var(--hi-v4-color-gray-50, #f5f7fa); }\n.hi-v4-tabs--vertical .hi-v4-tabs__list--desc .hi-v4-tabs__item:not(.hi-v4-tabs__item--active):hover {\n background-color: #ebedf0;\n background-color: var(--hi-v4-color-gray-200, #ebedf0);\n color: #929aa6;\n color: var(--hi-v4-color-gray-500, #929aa6); }\n.hi-v4-tabs--vertical .hi-v4-tabs__list--desc .hi-v4-tabs__item--active {\n color: #237ffa;\n color: var(--hi-v4-color-brandblue-500, #237ffa);\n background-color: #e2f3fe;\n background-color: var(--hi-v4-color-brandblue-50, #e2f3fe); }\n.hi-v4-tabs--vertical .hi-v4-tabs__list--desc .hi-v4-tabs__item--active .hi-v4-tabs-item__title {\n color: #237ffa;\n color: var(--hi-v4-color-brandblue-500, #237ffa); }\n.hi-v4-tabs--vertical .hi-v4-tabs__list--desc .hi-v4-tabs__item--active .hi-v4-tabs-item__desc {\n color: #237ffa;\n color: var(--hi-v4-color-brandblue-500, #237ffa); }\n.hi-v4-tabs--vertical .hi-v4-tabs__list--inner {\n width: auto;\n display: block;\n position: relative; }\n.hi-v4-tabs--vertical .hi-v4-tabs__list--scroll {\n -webkit-box-orient: vertical;\n -webkit-box-direction: normal;\n -ms-flex-direction: column;\n flex-direction: column;\n position: relative; }\n.hi-v4-tabs--vertical .hi-v4-tabs__item {\n line-height: 1.5rem;\n line-height: var(--hi-v4-text-lineheight-lg, 1.5rem);\n padding: 8px 20px;\n padding: var(--hi-v4-spacing-4, 8px) var(--hi-v4-spacing-10, 20px);\n margin: 0;\n -webkit-transition: all 0.2s cubic-bezier(0.34, 0.69, 0.1, 1);\n transition: all 0.2s cubic-bezier(0.34, 0.69, 0.1, 1); }\n.hi-v4-tabs--vertical .hi-v4-tabs__item--prev {\n border-top: 1px dashed #237ffa;\n border-top: 1px dashed var(--hi-v4-color-brandblue-500, #237ffa);\n border-left: none; }\n.hi-v4-tabs--vertical .hi-v4-tabs__item--next {\n border-bottom: 1px dashed #237ffa;\n border-bottom: 1px dashed var(--hi-v4-color-brandblue-500, #237ffa);\n border-right: none; }\n.hi-v4-tabs--vertical .hi-v4-tabs__content {\n padding-left: 16px;\n padding-top: 0; }\n.hi-v4-tabs--vertical .hi-v4-tabs__ink {\n position: absolute;\n left: 0;\n bottom: auto;\n width: 2px;\n background-color: #237ffa;\n background-color: var(--hi-v4-color-brandblue-500, #237ffa);\n -webkit-transition: top 0.2s cubic-bezier(0.34, 0.69, 0.1, 1), height 0.2s cubic-bezier(0.34, 0.69, 0.1, 1);\n transition: top 0.2s cubic-bezier(0.34, 0.69, 0.1, 1), height 0.2s cubic-bezier(0.34, 0.69, 0.1, 1); }\n.hi-v4-tabs__ink {\n position: absolute;\n bottom: 0;\n right: auto;\n top: auto;\n height: 2px;\n background-color: #237ffa;\n background-color: var(--hi-v4-color-brandblue-500, #237ffa);\n -webkit-transition: left 0.2s cubic-bezier(0.34, 0.69, 0.1, 1), width 0.2s cubic-bezier(0.34, 0.69, 0.1, 1);\n transition: left 0.2s cubic-bezier(0.34, 0.69, 0.1, 1), width 0.2s cubic-bezier(0.34, 0.69, 0.1, 1); }\n.hi-v4-tabs__item {\n line-height: 1.5rem;\n line-height: var(--hi-v4-text-lineheight-lg, 1.5rem);\n padding: 8px 20px;\n padding: var(--hi-v4-spacing-4, 8px) var(--hi-v4-spacing-10, 20px);\n margin: 0;\n cursor: pointer;\n -ms-flex-negative: 0;\n flex-shrink: 0;\n -webkit-transition: all 0.2s cubic-bezier(0.34, 0.69, 0.1, 1);\n transition: all 0.2s cubic-bezier(0.34, 0.69, 0.1, 1); }\n.hi-v4-tabs__item:not(.hi-v4-tabs__item--disabled):hover {\n color: #237ffa;\n color: var(--hi-v4-color-brandblue-500, #237ffa); }\n.hi-v4-tabs__item--active {\n color: #237ffa;\n color: var(--hi-v4-color-brandblue-500, #237ffa); }\n.hi-v4-tabs__item--prev {\n border-left: 1px dashed #237ffa;\n border-left: 1px dashed var(--hi-v4-color-brandblue-500, #237ffa); }\n.hi-v4-tabs__item--next {\n border-right: 1px dashed #237ffa;\n border-right: 1px dashed var(--hi-v4-color-brandblue-500, #237ffa); }\n.hi-v4-tabs__item--disabled {\n color: #929aa6 !important;\n color: var(--hi-v4-color-gray-500, #929aa6) !important;\n cursor: not-allowed; }\n.hi-v4-tabs__item:not(.hi-v4-tabs__item--active) {\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis; }\n.hi-v4-tabs__content {\n width: 100%;\n overflow: hidden;\n padding-top: 16px;\n padding-top: var(--hi-v4-spacing-8, 16px);\n -webkit-box-sizing: border-box;\n box-sizing: border-box; }\n";
|
|
15
|
+
var css_248z = ".hi-v4-tabs__add-btn.hi-v4-icon-button {font-size: var(--hi-v4-text-size-md, 0.875rem); }.hi-v4-tabs__up-btn.hi-v4-icon-button, .hi-v4-tabs__down-btn.hi-v4-icon-button, .hi-v4-tabs__left-btn.hi-v4-icon-button, .hi-v4-tabs__right-btn.hi-v4-icon-button {margin: var(--hi-v4-spacing-1, 2px); }.hi-v4-tabs__close-btn {cursor: pointer;color: var(--hi-v4-color-gray-500, #929aa6);margin-left: var(--hi-v4-spacing-2, 4px);-webkit-transition: color 0.3s;transition: color 0.3s; }.hi-v4-tabs__close-btn:hover {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-tabs--card .hi-v4-tabs__content {background-color: var(--hi-v4-color-static-white, #fff); }.hi-v4-tabs__list {position: relative;font-size: var(--hi-v4-text-size-md, 0.875rem);color: var(--hi-v4-color-gray-500, #929aa6);display: -webkit-box;display: -ms-flexbox;display: flex;overflow: hidden;-webkit-box-align: center;-ms-flex-align: center;align-items: center; }.hi-v4-tabs__list--card .hi-v4-tabs__item {background-color: var(--hi-v4-color-gray-200, #ebedf0);margin: 0;padding: var(--hi-v4-spacing-4, 8px) var(--hi-v4-spacing-10, 20px);border-radius: var(--hi-v4-border-radius-md, 4px) var(--hi-v4-border-radius-md, 4px) 0 0;-webkit-transition: all 0.3s;transition: all 0.3s; }.hi-v4-tabs__list--card .hi-v4-tabs__item--active {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));background-color: var(--hi-v4-color-static-white, #fff); }.hi-v4-tabs__list--button .hi-v4-tabs__item {margin: var(--hi-v4-spacing-2, 4px) var(--hi-v4-spacing-2, 4px) var(--hi-v4-spacing-2, 4px) 0;padding: var(--hi-v4-spacing-2, 4px) var(--hi-v4-spacing-10, 20px);border-radius: var(--hi-v4-border-radius-md, 4px);-webkit-transition: all 0.3s;transition: all 0.3s; }.hi-v4-tabs__list--button .hi-v4-tabs__item:not(.hi-v4-tabs__item--active):hover {background-color: var(--hi-v4-color-gray-200, #ebedf0);color: var(--hi-v4-color-gray-500, #929aa6); }.hi-v4-tabs__list--button .hi-v4-tabs__item--active {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));background-color: var(--hi-v4-color-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe)); }.hi-v4-tabs__list--desc {padding: 0 var(--hi-v4-spacing-10, 20px); }.hi-v4-tabs__list--desc .hi-v4-tabs-item__title {color: var(--hi-v4-color-gray-700, #1f2733); }.hi-v4-tabs__list--desc .hi-v4-tabs-item__desc {color: var(--hi-v4-color-gray-500, #929aa6);font-size: var(--hi-v4-text-size-sm, 0.75rem);line-height: var(--hi-v4-text-lineheight-sm, 1.25rem); }.hi-v4-tabs__list--desc .hi-v4-tabs__item {background: var(--hi-v4-color-gray-50, #f5f7fa);display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-orient: vertical;-webkit-box-direction: normal;-ms-flex-direction: column;flex-direction: column;-webkit-box-align: center;-ms-flex-align: center;align-items: center;margin: var(--hi-v4-spacing-10, 20px) var(--hi-v4-spacing-6, 12px) var(--hi-v4-spacing-10, 20px) 0;padding: var(--hi-v4-spacing-8, 16px) var(--hi-v4-spacing-10, 20px);border-radius: var(--hi-v4-border-radius-md, 4px);-webkit-transition: all 0.3s;transition: all 0.3s; }.hi-v4-tabs__list--desc .hi-v4-tabs__item:not(.hi-v4-tabs__item--active):hover {background-color: var(--hi-v4-color-gray-200, #ebedf0);color: var(--hi-v4-color-gray-500, #929aa6); }.hi-v4-tabs__list--desc .hi-v4-tabs__item--active {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));background-color: var(--hi-v4-color-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe)); }.hi-v4-tabs__list--desc .hi-v4-tabs__item--active .hi-v4-tabs-item__title {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-tabs__list--desc .hi-v4-tabs__item--active .hi-v4-tabs-item__desc {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-tabs__list--inner {display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-flex: 1;-ms-flex: 1 1;flex: 1 1;position: relative;overflow: hidden; }.hi-v4-tabs__list--scroll {display: -webkit-box;display: -ms-flexbox;display: flex;position: relative;-ms-flex-negative: 0;flex-shrink: 0;-webkit-transition-property: -webkit-transform;transition-property: -webkit-transform;transition-property: transform;transition-property: transform, -webkit-transform;-webkit-transition-duration: var(--hi-v4-motion-duration-slow, 300ms);transition-duration: var(--hi-v4-motion-duration-slow, 300ms);-webkit-transition-timing-function: var(--hi-v4-motion-bezier-easing, cubic-bezier(0.37, 0.02, 0.34, 1));transition-timing-function: var(--hi-v4-motion-bezier-easing, cubic-bezier(0.37, 0.02, 0.34, 1));will-change: transform; }.hi-v4-tabs--placement-vertical {display: -webkit-box;display: -ms-flexbox;display: flex; }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__content {padding-left: 16px;padding-top: 0; }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__list {-ms-flex-negative: 0;flex-shrink: 0;-webkit-box-orient: vertical;-webkit-box-direction: normal;-ms-flex-direction: column;flex-direction: column; }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__list .hi-v4-tabs__list--inner {width: auto;display: block;position: relative; }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__list .hi-v4-tabs__list--scroll {-webkit-box-orient: vertical;-webkit-box-direction: normal;-ms-flex-direction: column;flex-direction: column;position: relative; }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__list .hi-v4-tabs__item {line-height: var(--hi-v4-text-lineheight-lg, 1.5rem);padding: var(--hi-v4-spacing-4, 8px) var(--hi-v4-spacing-10, 20px);margin: 0;-webkit-transition: all 0.2s cubic-bezier(0.34, 0.69, 0.1, 1);transition: all 0.2s cubic-bezier(0.34, 0.69, 0.1, 1); }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__list .hi-v4-tabs__item--prev {border-top: 1px dashed var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));border-left: none; }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__list .hi-v4-tabs__item--next {border-bottom: 1px dashed var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));border-right: none; }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__list .hi-v4-tabs__ink {position: absolute;left: 0;bottom: auto;width: 2px;background-color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));-webkit-transition: top 0.2s cubic-bezier(0.34, 0.69, 0.1, 1), height 0.2s cubic-bezier(0.34, 0.69, 0.1, 1);transition: top 0.2s cubic-bezier(0.34, 0.69, 0.1, 1), height 0.2s cubic-bezier(0.34, 0.69, 0.1, 1); }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__list .hi-v4-tabs__list--card .hi-v4-tabs__item {margin: 0;padding: var(--hi-v4-spacing-4, 8px) var(--hi-v4-spacing-10, 20px);background-color: var(--hi-v4-color-gray-200, #ebedf0);border-radius: var(--hi-v4-border-radius-md, 4px) 0 0 var(--hi-v4-border-radius-md, 4px);-webkit-transition: all 0.3s;transition: all 0.3s; }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__list .hi-v4-tabs__list--card .hi-v4-tabs__item--active {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));background-color: var(--hi-v4-color-static-white, #fff); }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__list .hi-v4-tabs__list--button .hi-v4-tabs__item {margin: 0 0 var(--hi-v4-spacing-2, 4px) 0;padding: var(--hi-v4-spacing-2, 4px) var(--hi-v4-spacing-10, 20px);border-radius: var(--hi-v4-border-radius-md, 4px);-webkit-transition: all 0.3s;transition: all 0.3s; }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__list .hi-v4-tabs__list--button .hi-v4-tabs__item:not(.hi-v4-tabs__item--active):hover {background-color: var(--hi-v4-color-gray-200, #ebedf0);color: var(--hi-v4-color-gray-500, #929aa6); }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__list .hi-v4-tabs__list--button .hi-v4-tabs__item--active {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));background-color: var(--hi-v4-color-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe)); }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__list .hi-v4-tabs__list--desc .hi-v4-tabs-item__title {color: var(--hi-v4-color-gray-700, #1f2733); }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__list .hi-v4-tabs__list--desc .hi-v4-tabs-item__desc {color: var(--hi-v4-color-gray-500, #929aa6);font-size: var(--hi-v4-text-size-sm, 0.75rem);line-height: var(--hi-v4-text-lineheight-sm, 1.25rem); }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__list .hi-v4-tabs__list--desc .hi-v4-tabs__item {display: -webkit-box;display: -ms-flexbox;display: flex;-webkit-box-orient: vertical;-webkit-box-direction: normal;-ms-flex-direction: column;flex-direction: column;-webkit-box-align: center;-ms-flex-align: center;align-items: center;margin: 0 0 var(--hi-v4-spacing-6, 12px) 0;padding: var(--hi-v4-spacing-8, 16px) var(--hi-v4-spacing-10, 20px);border-radius: var(--hi-v4-border-radius-md, 4px);-webkit-transition: all 0.3s;transition: all 0.3s;background: var(--hi-v4-color-gray-50, #f5f7fa); }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__list .hi-v4-tabs__list--desc .hi-v4-tabs__item:not(.hi-v4-tabs__item--active):hover {background-color: var(--hi-v4-color-gray-200, #ebedf0);color: var(--hi-v4-color-gray-500, #929aa6); }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__list .hi-v4-tabs__list--desc .hi-v4-tabs__item--active {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));background-color: var(--hi-v4-color-primary-50, var(--hi-v4-color-brandblue-50, #e2f3fe)); }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__list .hi-v4-tabs__list--desc .hi-v4-tabs__item--active .hi-v4-tabs-item__title {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-tabs--placement-vertical > .hi-v4-tabs__list .hi-v4-tabs__list--desc .hi-v4-tabs__item--active .hi-v4-tabs-item__desc {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-tabs__ink {position: absolute;bottom: 0;right: auto;top: auto;height: 2px;background-color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa));-webkit-transition: left 0.2s cubic-bezier(0.34, 0.69, 0.1, 1), width 0.2s cubic-bezier(0.34, 0.69, 0.1, 1);transition: left 0.2s cubic-bezier(0.34, 0.69, 0.1, 1), width 0.2s cubic-bezier(0.34, 0.69, 0.1, 1); }.hi-v4-tabs__item {line-height: var(--hi-v4-text-lineheight-lg, 1.5rem);padding: var(--hi-v4-spacing-4, 8px) var(--hi-v4-spacing-10, 20px);margin: 0;cursor: pointer;-ms-flex-negative: 0;flex-shrink: 0;-webkit-transition: all 0.2s cubic-bezier(0.34, 0.69, 0.1, 1);transition: all 0.2s cubic-bezier(0.34, 0.69, 0.1, 1); }.hi-v4-tabs__item:focus {outline: 0; }.hi-v4-tabs__item:not(.hi-v4-tabs__item--disabled):hover {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-tabs__item--active {color: var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-tabs__item--prev {border-left: 1px dashed var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-tabs__item--next {border-right: 1px dashed var(--hi-v4-color-primary-500, var(--hi-v4-color-brandblue-500, #237ffa)); }.hi-v4-tabs__item--disabled {color: var(--hi-v4-color-gray-500, #929aa6) !important;cursor: not-allowed; }.hi-v4-tabs__item:not(.hi-v4-tabs__item--active) {overflow: hidden;white-space: nowrap;text-overflow: ellipsis; }.hi-v4-tabs__content {width: 100%;overflow: hidden;padding-top: var(--hi-v4-spacing-8, 16px);-webkit-box-sizing: border-box;box-sizing: border-box; }";
|
|
16
16
|
|
|
17
|
-
var __styleInject__ = require('
|
|
17
|
+
var __styleInject__ = require('inject-head-style')["default"];
|
|
18
18
|
|
|
19
19
|
__styleInject__(css_248z);
|
|
20
20
|
|
|
21
21
|
exports["default"] = css_248z;
|
|
22
|
-
//# sourceMappingURL=index.scss.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** @LICENSE
|
|
2
|
+
* @hi-ui/tabs
|
|
3
|
+
* https://github.com/XiaoMi/hiui/tree/master/packages/ui/tabs#readme
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) HIUI <mi-hiui@xiaomi.com>.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(exports, '__esModule', {
|
|
13
|
+
value: true
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
var typeAssertion = require('@hi-ui/type-assertion');
|
|
17
|
+
|
|
18
|
+
var getNextTabId = function getNextTabId(data, tabId) {
|
|
19
|
+
if (typeAssertion.isArrayNonEmpty(data)) {
|
|
20
|
+
var itemIndex = data.findIndex(function (item) {
|
|
21
|
+
return item.tabId === tabId;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
if (itemIndex !== -1 && data[itemIndex + 1]) {
|
|
25
|
+
return data[itemIndex + 1].tabId;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return null;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.getNextTabId = getNextTabId;
|
package/lib/esm/TabInk.js
CHANGED
|
@@ -15,42 +15,47 @@ var TabInk = function TabInk(_ref) {
|
|
|
15
15
|
|
|
16
16
|
var disabled = _ref.disabled,
|
|
17
17
|
prefixCls = _ref.prefixCls,
|
|
18
|
-
|
|
19
|
-
tabListRef = _ref.tabListRef,
|
|
18
|
+
activeItemElement = _ref.activeItemElement,
|
|
20
19
|
direction = _ref.direction,
|
|
21
|
-
|
|
20
|
+
activeTabId = _ref.activeTabId,
|
|
21
|
+
getTabOffset = _ref.getTabOffset;
|
|
22
22
|
var inkRef = useRef(null);
|
|
23
23
|
useEffect(function () {
|
|
24
|
-
if (inkRef.current
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
if (!inkRef.current) return;
|
|
25
|
+
if (!activeItemElement) return;
|
|
26
|
+
var computedStyle = getComputedStyle(activeItemElement);
|
|
27
|
+
var itemRect = activeItemElement.getBoundingClientRect();
|
|
28
|
+
var offset = getTabOffset(activeTabId);
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
_style = {
|
|
31
|
-
top: itemRect.top - listRect.top - translate + 2 + 8 + "px",
|
|
32
|
-
height: itemRect.height - 4 - 16 + "px",
|
|
33
|
-
left: '',
|
|
34
|
-
width: ''
|
|
35
|
-
};
|
|
36
|
-
} else {
|
|
37
|
-
_style = {
|
|
38
|
-
left: itemRect.left - listRect.left - translate + 20 + "px",
|
|
39
|
-
width: itemRect.width - 40 + "px",
|
|
40
|
-
top: '',
|
|
41
|
-
height: ''
|
|
42
|
-
};
|
|
43
|
-
}
|
|
30
|
+
var _style;
|
|
44
31
|
|
|
45
|
-
|
|
32
|
+
if (direction === 'vertical') {
|
|
33
|
+
var paddingTop = parseFloat(computedStyle.getPropertyValue('padding-top'));
|
|
34
|
+
var paddingBottom = parseFloat(computedStyle.getPropertyValue('padding-bottom'));
|
|
35
|
+
_style = {
|
|
36
|
+
// 2px 保证尽量和文字顶部对齐,减少文本行高的影响
|
|
37
|
+
top: offset + paddingTop + 2 + 'px',
|
|
38
|
+
height: itemRect.height - paddingTop - paddingBottom - 4 + "px",
|
|
39
|
+
left: '',
|
|
40
|
+
width: ''
|
|
41
|
+
};
|
|
42
|
+
} else {
|
|
43
|
+
var paddingLeft = parseFloat(computedStyle.getPropertyValue('padding-left'));
|
|
44
|
+
var paddingRight = parseFloat(computedStyle.getPropertyValue('padding-right'));
|
|
45
|
+
_style = {
|
|
46
|
+
left: offset + paddingLeft + 'px',
|
|
47
|
+
width: itemRect.width - paddingRight - paddingLeft + "px",
|
|
48
|
+
top: '',
|
|
49
|
+
height: ''
|
|
50
|
+
};
|
|
46
51
|
}
|
|
47
|
-
|
|
52
|
+
|
|
53
|
+
Object.assign(inkRef.current.style, _style);
|
|
54
|
+
}, [activeItemElement, direction, activeTabId, getTabOffset]);
|
|
48
55
|
return /*#__PURE__*/React.createElement("div", {
|
|
49
56
|
className: cx(prefixCls + "__ink", (_cx = {}, _cx[prefixCls + "__ink--disabled"] = disabled, _cx)),
|
|
50
57
|
ref: inkRef
|
|
51
58
|
});
|
|
52
59
|
};
|
|
53
60
|
|
|
54
|
-
export default TabInk;
|
|
55
61
|
export { TabInk };
|
|
56
|
-
//# sourceMappingURL=TabInk.js.map
|
package/lib/esm/TabItem.js
CHANGED
package/lib/esm/TabList.js
CHANGED
|
@@ -7,46 +7,49 @@
|
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
9
|
*/
|
|
10
|
-
import
|
|
10
|
+
import { __rest } from 'tslib';
|
|
11
|
+
import React, { forwardRef, useState, useCallback, useRef } from 'react';
|
|
11
12
|
import { __DEV__ } from '@hi-ui/env';
|
|
12
13
|
import { TabItem } from './TabItem.js';
|
|
13
14
|
import { useUncontrolledState } from '@hi-ui/use-uncontrolled-state';
|
|
14
15
|
import { getPrefixCls, cx } from '@hi-ui/classname';
|
|
15
16
|
import { TabInk } from './TabInk.js';
|
|
16
17
|
import { LeftOutlined, UpOutlined, RightOutlined, DownOutlined, PlusOutlined } from '@hi-ui/icons';
|
|
17
|
-
import { isUndef } from '@hi-ui/type-assertion';
|
|
18
|
+
import { isUndef, isArrayNonEmpty } from '@hi-ui/type-assertion';
|
|
18
19
|
import { IconButton } from '@hi-ui/icon-button';
|
|
20
|
+
import { useResizeObserver } from './hooks/index.js';
|
|
21
|
+
import { useLatestCallback } from '@hi-ui/use-latest';
|
|
22
|
+
import { getNextTabId } from './utils/index.js';
|
|
19
23
|
var _role = 'tabs';
|
|
20
24
|
|
|
21
25
|
var _prefix = getPrefixCls(_role);
|
|
22
26
|
|
|
23
|
-
var TabList = /*#__PURE__*/forwardRef(function (
|
|
27
|
+
var TabList = /*#__PURE__*/forwardRef(function (_a, ref) {
|
|
24
28
|
var _cx;
|
|
25
29
|
|
|
26
|
-
var data =
|
|
27
|
-
className =
|
|
28
|
-
style =
|
|
29
|
-
activeId =
|
|
30
|
-
defaultActiveId =
|
|
31
|
-
onChange =
|
|
32
|
-
onTabClick =
|
|
33
|
-
|
|
34
|
-
prefixCls =
|
|
35
|
-
|
|
36
|
-
direction =
|
|
37
|
-
editable =
|
|
38
|
-
onAdd =
|
|
39
|
-
onDelete =
|
|
40
|
-
draggable =
|
|
41
|
-
onDragStart =
|
|
42
|
-
onDragOver =
|
|
43
|
-
onDrop =
|
|
44
|
-
onDragEnd =
|
|
45
|
-
|
|
46
|
-
type =
|
|
47
|
-
extra =
|
|
48
|
-
|
|
49
|
-
var _a;
|
|
30
|
+
var data = _a.data,
|
|
31
|
+
className = _a.className,
|
|
32
|
+
style = _a.style,
|
|
33
|
+
activeId = _a.activeId,
|
|
34
|
+
defaultActiveId = _a.defaultActiveId,
|
|
35
|
+
onChange = _a.onChange,
|
|
36
|
+
onTabClick = _a.onTabClick,
|
|
37
|
+
_a$prefixCls = _a.prefixCls,
|
|
38
|
+
prefixCls = _a$prefixCls === void 0 ? _prefix : _a$prefixCls,
|
|
39
|
+
_a$direction = _a.direction,
|
|
40
|
+
direction = _a$direction === void 0 ? 'horizontal' : _a$direction,
|
|
41
|
+
editable = _a.editable,
|
|
42
|
+
onAdd = _a.onAdd,
|
|
43
|
+
onDelete = _a.onDelete,
|
|
44
|
+
draggable = _a.draggable,
|
|
45
|
+
onDragStart = _a.onDragStart,
|
|
46
|
+
onDragOver = _a.onDragOver,
|
|
47
|
+
onDrop = _a.onDrop,
|
|
48
|
+
onDragEnd = _a.onDragEnd,
|
|
49
|
+
_a$type = _a.type,
|
|
50
|
+
type = _a$type === void 0 ? 'line' : _a$type,
|
|
51
|
+
extra = _a.extra,
|
|
52
|
+
rest = __rest(_a, ["data", "className", "style", "activeId", "defaultActiveId", "onChange", "onTabClick", "prefixCls", "direction", "editable", "onAdd", "onDelete", "draggable", "onDragStart", "onDragOver", "onDrop", "onDragEnd", "type", "extra"]);
|
|
50
53
|
|
|
51
54
|
var _useUncontrolledState = useUncontrolledState(function () {
|
|
52
55
|
if (isUndef(defaultActiveId)) {
|
|
@@ -54,101 +57,163 @@ var TabList = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
return defaultActiveId;
|
|
57
|
-
}, activeId, onChange),
|
|
60
|
+
}, activeId, onChange, Object.is),
|
|
58
61
|
activeTabId = _useUncontrolledState[0],
|
|
59
62
|
setActiveTabId = _useUncontrolledState[1];
|
|
60
63
|
|
|
61
64
|
var _useState = useState(null),
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
innerElement = _useState[0],
|
|
66
|
+
setInnerElement = _useState[1];
|
|
64
67
|
|
|
65
68
|
var _useState2 = useState(null),
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
scrollElement = _useState2[0],
|
|
70
|
+
setScrollElement = _useState2[1];
|
|
71
|
+
|
|
72
|
+
var showHorizontal = direction === 'horizontal';
|
|
73
|
+
var getClientSize = useCallback(function (element) {
|
|
74
|
+
return showHorizontal ? element.clientWidth : element.clientHeight;
|
|
75
|
+
}, [showHorizontal]);
|
|
68
76
|
|
|
69
77
|
var _useState3 = useState(0),
|
|
70
|
-
|
|
71
|
-
|
|
78
|
+
translatePos = _useState3[0],
|
|
79
|
+
setTranslatePos = _useState3[1];
|
|
72
80
|
|
|
73
81
|
var _useState4 = useState(0),
|
|
74
|
-
|
|
75
|
-
|
|
82
|
+
translateBoundPos = _useState4[0],
|
|
83
|
+
setTranslateBoundPos = _useState4[1];
|
|
76
84
|
|
|
77
85
|
var itemsRef = useRef({});
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
86
|
+
|
|
87
|
+
var _useState5 = useState(false),
|
|
88
|
+
showScrollBtn = _useState5[0],
|
|
89
|
+
setShowScrollBtn = _useState5[1];
|
|
90
|
+
|
|
91
|
+
var resizeScroll = function resizeScroll(scrollSize, innerSize) {
|
|
92
|
+
var showScrollBtn = scrollSize > innerSize;
|
|
93
|
+
setShowScrollBtn(showScrollBtn);
|
|
94
|
+
|
|
95
|
+
if (showScrollBtn) {
|
|
96
|
+
setTranslateBoundPos(scrollSize - innerSize);
|
|
97
|
+
}
|
|
98
|
+
}; // 响应式滚动按钮展示
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
useResizeObserver({
|
|
102
|
+
element: innerElement,
|
|
103
|
+
getSize: getClientSize,
|
|
104
|
+
onResize: function onResize(_, innerSize) {
|
|
105
|
+
if (scrollElement) {
|
|
106
|
+
var scrollSize = getClientSize(scrollElement);
|
|
107
|
+
resizeScroll(scrollSize, innerSize);
|
|
108
|
+
}
|
|
81
109
|
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
110
|
+
});
|
|
111
|
+
useResizeObserver({
|
|
112
|
+
element: scrollElement,
|
|
113
|
+
getSize: getClientSize,
|
|
114
|
+
onResize: function onResize(_, scrollSize) {
|
|
115
|
+
if (innerElement) {
|
|
116
|
+
var innerSize = getClientSize(innerElement);
|
|
117
|
+
resizeScroll(scrollSize, innerSize);
|
|
118
|
+
}
|
|
86
119
|
}
|
|
120
|
+
});
|
|
121
|
+
var getTabPos = useCallback(function (tabId) {
|
|
122
|
+
var target = 0; // 获取目标元素的位置
|
|
123
|
+
|
|
124
|
+
var targetElement = itemsRef.current[tabId];
|
|
87
125
|
|
|
88
|
-
if (
|
|
89
|
-
|
|
126
|
+
if (targetElement) {
|
|
127
|
+
var rect = targetElement.getBoundingClientRect();
|
|
128
|
+
target = showHorizontal ? rect.left : rect.top;
|
|
90
129
|
}
|
|
91
|
-
}, [activeTabId, onTabClick, setActiveTabId]);
|
|
92
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
93
|
-
style: style,
|
|
94
|
-
className: cx(prefixCls + "__list", (_cx = {}, _cx[prefixCls + "__list--" + type] = type, _cx), className),
|
|
95
|
-
ref: ref
|
|
96
|
-
}, showScrollBtn && direction === 'horizontal' && /*#__PURE__*/React.createElement(IconButton, {
|
|
97
|
-
className: prefixCls + "__left-btn",
|
|
98
|
-
effect: true,
|
|
99
|
-
icon: /*#__PURE__*/React.createElement(LeftOutlined, null),
|
|
100
|
-
onClick: function onClick() {
|
|
101
|
-
if (scrollRef && innerRef) {
|
|
102
|
-
var canScroll = -translateX - innerRef.clientWidth;
|
|
103
|
-
var moveWidth = 0;
|
|
104
130
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
131
|
+
return target;
|
|
132
|
+
}, [showHorizontal]);
|
|
133
|
+
var getTabOffset = useCallback(function (tabId) {
|
|
134
|
+
// 获取目标元素的位置
|
|
135
|
+
var targetPos = getTabPos(tabId); // 获取基准元素的位置(第一个)
|
|
136
|
+
|
|
137
|
+
var basePos = 0;
|
|
138
|
+
|
|
139
|
+
if (isArrayNonEmpty(data)) {
|
|
140
|
+
var baseItem = data[0];
|
|
141
|
+
basePos = getTabPos(baseItem.tabId);
|
|
142
|
+
} // 返回目标元素相对基准元素的偏移量
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
return targetPos ? targetPos - basePos : 0;
|
|
146
|
+
}, [data, getTabPos]);
|
|
110
147
|
|
|
111
|
-
|
|
148
|
+
var syncScrollPosition = function syncScrollPosition(tabId) {
|
|
149
|
+
if (!innerElement) return;
|
|
150
|
+
if (!scrollElement) return;
|
|
151
|
+
var scrollSize = getClientSize(scrollElement);
|
|
152
|
+
var innerSize = getClientSize(innerElement);
|
|
153
|
+
var offsetValue = getTabOffset(tabId); // 左边或上半部内容展示不全
|
|
154
|
+
|
|
155
|
+
var currentOffset = -translatePos;
|
|
156
|
+
|
|
157
|
+
if (offsetValue < currentOffset) {
|
|
158
|
+
setTranslatePos(-offsetValue);
|
|
159
|
+
} else {
|
|
160
|
+
// 右边或下半部内容展示不全
|
|
161
|
+
var nextTabId = getNextTabId(data, tabId);
|
|
162
|
+
var nextOffsetValue = nextTabId !== null ? getTabOffset(nextTabId) : scrollSize;
|
|
163
|
+
|
|
164
|
+
var _currentOffset = -translatePos + innerSize;
|
|
165
|
+
|
|
166
|
+
if (nextOffsetValue > _currentOffset) {
|
|
167
|
+
setTranslatePos(translatePos - (nextOffsetValue - _currentOffset));
|
|
112
168
|
}
|
|
113
169
|
}
|
|
114
|
-
}
|
|
115
|
-
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
var onClickTab = useLatestCallback(function (tabId, event) {
|
|
173
|
+
onTabClick === null || onTabClick === void 0 ? void 0 : onTabClick(tabId, event);
|
|
174
|
+
setActiveTabId(tabId);
|
|
175
|
+
syncScrollPosition(tabId);
|
|
176
|
+
});
|
|
177
|
+
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
178
|
+
style: style,
|
|
179
|
+
className: cx(prefixCls + "__list", (_cx = {}, _cx[prefixCls + "__list--" + type] = type, _cx), className),
|
|
180
|
+
ref: ref
|
|
181
|
+
}, rest), showScrollBtn ? /*#__PURE__*/React.createElement(IconButton, {
|
|
182
|
+
className: showHorizontal ? prefixCls + "__left-btn" : prefixCls + "__up-btn",
|
|
116
183
|
effect: true,
|
|
117
|
-
|
|
184
|
+
disabled: translatePos === 0,
|
|
185
|
+
icon: showHorizontal ? /*#__PURE__*/React.createElement(LeftOutlined, null) : /*#__PURE__*/React.createElement(UpOutlined, null),
|
|
118
186
|
onClick: function onClick() {
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
var moveWidth = 0;
|
|
122
|
-
|
|
123
|
-
if (canScroll >= 0) {
|
|
124
|
-
moveWidth = innerRef.clientHeight;
|
|
125
|
-
} else {
|
|
126
|
-
moveWidth = -translateY;
|
|
127
|
-
}
|
|
187
|
+
if (!scrollElement) return;
|
|
188
|
+
if (!innerElement) return; // 向前面滚动
|
|
128
189
|
|
|
129
|
-
|
|
130
|
-
|
|
190
|
+
var clientSize = getClientSize(innerElement);
|
|
191
|
+
var canScroll = -translatePos - clientSize;
|
|
192
|
+
var moveWidth = canScroll >= 0 ? clientSize : -translatePos;
|
|
193
|
+
setTranslatePos(function (prev) {
|
|
194
|
+
return prev + moveWidth;
|
|
195
|
+
});
|
|
131
196
|
}
|
|
132
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
197
|
+
}) : null, /*#__PURE__*/React.createElement("div", {
|
|
133
198
|
className: cx(prefixCls + "__list--inner"),
|
|
134
|
-
ref:
|
|
199
|
+
ref: setInnerElement
|
|
135
200
|
}, /*#__PURE__*/React.createElement("div", {
|
|
136
201
|
className: cx(prefixCls + "__list--scroll"),
|
|
137
|
-
ref:
|
|
202
|
+
ref: setScrollElement,
|
|
138
203
|
style: showScrollBtn ? {
|
|
139
|
-
transform: direction === 'horizontal' ? "translateX(" +
|
|
140
|
-
} :
|
|
141
|
-
}, data.map(function (
|
|
204
|
+
transform: direction === 'horizontal' ? "translateX(" + translatePos + "px)" : "translateY(" + translatePos + "px)"
|
|
205
|
+
} : undefined
|
|
206
|
+
}, data.map(function (item, index) {
|
|
142
207
|
return /*#__PURE__*/React.createElement(TabItem, Object.assign({
|
|
143
208
|
key: index
|
|
144
|
-
},
|
|
209
|
+
}, item, {
|
|
145
210
|
ref: function ref(node) {
|
|
146
|
-
itemsRef.current["" +
|
|
211
|
+
itemsRef.current["" + item.tabId] = node;
|
|
147
212
|
},
|
|
148
213
|
type: type,
|
|
149
|
-
itemRef: itemsRef.current["" +
|
|
214
|
+
itemRef: itemsRef.current["" + item.tabId],
|
|
150
215
|
index: index,
|
|
151
|
-
active: activeTabId ===
|
|
216
|
+
active: activeTabId === item.tabId,
|
|
152
217
|
prefixCls: prefixCls,
|
|
153
218
|
draggable: draggable,
|
|
154
219
|
onTabClick: onClickTab,
|
|
@@ -160,49 +225,30 @@ var TabList = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
160
225
|
onDragEnd: onDragEnd,
|
|
161
226
|
direction: direction
|
|
162
227
|
}));
|
|
163
|
-
}), type === 'line'
|
|
164
|
-
translate: direction === 'horizontal' ? translateX : translateY,
|
|
228
|
+
}), type === 'line' ? /*#__PURE__*/React.createElement(TabInk, {
|
|
165
229
|
prefixCls: prefixCls,
|
|
166
230
|
direction: direction,
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
231
|
+
activeItemElement: itemsRef.current[activeTabId],
|
|
232
|
+
activeTabId: activeTabId,
|
|
233
|
+
getTabOffset: getTabOffset
|
|
234
|
+
}) : null)), showScrollBtn ? /*#__PURE__*/React.createElement(IconButton, {
|
|
170
235
|
effect: true,
|
|
171
|
-
className: prefixCls + "__right-btn",
|
|
172
|
-
|
|
236
|
+
className: showHorizontal ? prefixCls + "__right-btn" : prefixCls + "__down-btn",
|
|
237
|
+
disabled: translateBoundPos === -translatePos,
|
|
238
|
+
icon: showHorizontal ? /*#__PURE__*/React.createElement(RightOutlined, null) : /*#__PURE__*/React.createElement(DownOutlined, null),
|
|
173
239
|
onClick: function onClick() {
|
|
174
|
-
if (
|
|
175
|
-
|
|
176
|
-
var moveWidth = 0;
|
|
177
|
-
|
|
178
|
-
if (canScroll >= innerRef.clientWidth) {
|
|
179
|
-
moveWidth = innerRef.clientWidth;
|
|
180
|
-
} else {
|
|
181
|
-
moveWidth = canScroll;
|
|
182
|
-
}
|
|
240
|
+
if (!scrollElement) return;
|
|
241
|
+
if (!innerElement) return; // 向后面滚动
|
|
183
242
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
onClick: function onClick() {
|
|
192
|
-
if (scrollRef && innerRef) {
|
|
193
|
-
var canScroll = scrollRef.clientHeight - innerRef.clientHeight + translateY;
|
|
194
|
-
var moveWidth = 0;
|
|
195
|
-
|
|
196
|
-
if (canScroll >= innerRef.clientHeight) {
|
|
197
|
-
moveWidth = innerRef.clientHeight;
|
|
198
|
-
} else {
|
|
199
|
-
moveWidth = canScroll;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
setTranslateY(translateY - moveWidth);
|
|
203
|
-
}
|
|
243
|
+
var scrollSize = getClientSize(scrollElement);
|
|
244
|
+
var innerSize = getClientSize(innerElement);
|
|
245
|
+
var canScrollWidth = scrollSize - innerSize + translatePos;
|
|
246
|
+
var moveWidth = canScrollWidth < innerSize ? canScrollWidth : innerSize;
|
|
247
|
+
setTranslatePos(function (prev) {
|
|
248
|
+
return prev - moveWidth;
|
|
249
|
+
});
|
|
204
250
|
}
|
|
205
|
-
}), editable ? /*#__PURE__*/React.createElement(IconButton, {
|
|
251
|
+
}) : null, editable ? /*#__PURE__*/React.createElement(IconButton, {
|
|
206
252
|
icon: /*#__PURE__*/React.createElement(PlusOutlined, null),
|
|
207
253
|
className: prefixCls + "__add-btn",
|
|
208
254
|
onClick: onAdd
|
|
@@ -214,4 +260,3 @@ if (__DEV__) {
|
|
|
214
260
|
}
|
|
215
261
|
|
|
216
262
|
export { TabList };
|
|
217
|
-
//# sourceMappingURL=TabList.js.map
|
package/lib/esm/TabPane.js
CHANGED
|
@@ -7,18 +7,23 @@
|
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
9
|
*/
|
|
10
|
+
import { __rest } from 'tslib';
|
|
10
11
|
import React from 'react';
|
|
12
|
+
import { filterProps } from '@hi-ui/react-utils';
|
|
13
|
+
var omitProps = ['tabId', 'tabTitle', 'disabled', 'tabDesc', 'closeable'];
|
|
11
14
|
|
|
12
|
-
var TabPane = function TabPane(
|
|
13
|
-
var children =
|
|
14
|
-
className =
|
|
15
|
-
style =
|
|
16
|
-
active =
|
|
17
|
-
|
|
15
|
+
var TabPane = function TabPane(_a) {
|
|
16
|
+
var children = _a.children,
|
|
17
|
+
className = _a.className,
|
|
18
|
+
style = _a.style,
|
|
19
|
+
active = _a.active,
|
|
20
|
+
rest = __rest(_a, ["children", "className", "style", "active"]);
|
|
21
|
+
|
|
22
|
+
var htmlProps = filterProps(rest, omitProps);
|
|
23
|
+
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
18
24
|
style: style,
|
|
19
25
|
className: className
|
|
20
|
-
}, active ? children : null);
|
|
26
|
+
}, htmlProps), active ? children : null);
|
|
21
27
|
};
|
|
22
28
|
|
|
23
29
|
export { TabPane };
|
|
24
|
-
//# sourceMappingURL=TabPane.js.map
|