@wonderflow/react-components 7.0.0 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/autocomplete/autocomplete.d.ts.map +1 -1
- package/dist/components/autocomplete/autocomplete.js +6 -6
- package/dist/components/container/container.d.ts +1 -1
- package/dist/components/container/container.d.ts.map +1 -1
- package/dist/components/container/container.module.css +1 -1
- package/dist/components/disclosure/disclosure.d.ts.map +1 -1
- package/dist/components/disclosure/disclosure.js +2 -2
- package/dist/components/drawer/drawer.d.ts.map +1 -1
- package/dist/components/drawer/drawer.js +2 -2
- package/dist/components/modal/modal.d.ts.map +1 -1
- package/dist/components/modal/modal.js +2 -2
- package/dist/components/overlay-container/overlay-container.d.ts.map +1 -1
- package/dist/components/overlay-container/overlay-container.js +2 -2
- package/dist/components/popover/popover.d.ts.map +1 -1
- package/dist/components/popover/popover.js +6 -6
- package/dist/components/spinner/spinner.d.ts.map +1 -1
- package/dist/components/spinner/spinner.js +6 -6
- package/dist/components/tab/tab.d.ts +27 -26
- package/dist/components/tab/tab.d.ts.map +1 -1
- package/dist/components/tab/tab.js +15 -32
- package/dist/components/tab/tab.module.css +1 -1
- package/dist/components/tab/tabs-panel.d.ts +10 -0
- package/dist/components/tab/tabs-panel.d.ts.map +1 -0
- package/dist/components/tab/tabs-panel.js +4 -0
- package/dist/components/table/table-controls/toggle-columns.js +2 -2
- package/dist/components/table/table.d.ts +42 -52
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/table/table.js +58 -62
- package/dist/components/table/types.d.ts +2 -2
- package/dist/components/table/types.d.ts.map +1 -1
- package/dist/components/toggle-button/toggle-button.d.ts.map +1 -1
- package/dist/components/toggle-button/toggle-button.js +4 -4
- package/package.json +2 -1
- package/dist/components/tab/primitive-tab.d.ts +0 -12
- package/dist/components/tab/primitive-tab.d.ts.map +0 -1
- package/dist/components/tab/primitive-tab.js +0 -51
- package/dist/components/tab/tab-item.d.ts +0 -23
- package/dist/components/tab/tab-item.d.ts.map +0 -1
- package/dist/components/tab/tab-item.js +0 -24
- package/dist/components/tab/tab-list.d.ts +0 -8
- package/dist/components/tab/tab-list.d.ts.map +0 -1
- package/dist/components/tab/tab-list.js +0 -11
- package/dist/components/tab/tab-panel.d.ts +0 -35
- package/dist/components/tab/tab-panel.d.ts.map +0 -1
- package/dist/components/tab/tab-panel.js +0 -16
- package/dist/components/tab/use-constant.d.ts +0 -2
- package/dist/components/tab/use-constant.d.ts.map +0 -1
- package/dist/components/tab/use-constant.js +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/autocomplete/autocomplete.tsx"],"names":[],"mappings":"AACA,OAAO,EAAsB,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACnF,OAAO,EACK,yBAAyB,EAEC,SAAS,EAC9C,MAAM,OAAO,CAAA;AAEd,OAAO,EAAyB,cAAc,EAAE,MAAM,cAAc,CAAA;AAKpE,oBAAY,iBAAiB,GAAG,cAAc,GAAG;IAC/C;;OAEG;IACH,QAAQ,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;CAC1B,CAAC;AAEF,aAAK,qBAAqB,GAAG,yBAAyB,CAAC,iBAAiB,CAAC,GAAG;IAC1E,MAAM,EAAE,yBAAyB,CAAC,uBAAuB,CAAC,CAAC;CAC5D,CAAA;AAqBD,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../src/components/autocomplete/autocomplete.tsx"],"names":[],"mappings":"AACA,OAAO,EAAsB,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACnF,OAAO,EACK,yBAAyB,EAEC,SAAS,EAC9C,MAAM,OAAO,CAAA;AAEd,OAAO,EAAyB,cAAc,EAAE,MAAM,cAAc,CAAA;AAKpE,oBAAY,iBAAiB,GAAG,cAAc,GAAG;IAC/C;;OAEG;IACH,QAAQ,CAAC,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;CAC1B,CAAC;AAEF,aAAK,qBAAqB,GAAG,yBAAyB,CAAC,iBAAiB,CAAC,GAAG;IAC1E,MAAM,EAAE,yBAAyB,CAAC,uBAAuB,CAAC,CAAC;CAC5D,CAAA;AAqBD,eAAO,MAAM,YAAY,uBA+IE,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { domMax, LazyMotion, m, AnimatePresence } from 'framer-motion';
|
|
3
3
|
import { AutocompleteOption } from './autocomplete-option';
|
|
4
4
|
import { Children, cloneElement, forwardRef, useCallback, useMemo, useRef, useState, useEffect, isValidElement } from 'react';
|
|
5
5
|
import { useDebounce, useFocusWithin, useKeyPress, useSize } from 'ahooks';
|
|
@@ -71,11 +71,11 @@ export const Autocomplete = forwardRef(({ children, onChange, disabled, readOnly
|
|
|
71
71
|
useEffect(() => {
|
|
72
72
|
value && setContent(String(value));
|
|
73
73
|
}, [value]);
|
|
74
|
-
return (_jsxs("div", { ref: autocompleteRef, className: styles.Autocomplete, "data-focus-within": isFocusWithin, children: [_jsx(Textfield, { ref: setTriggerRef, id: seedID('autocomplete-trigger'), "aria-haspopup": "true", "aria-controls": seedID('autocomplete-menu'), "aria-expanded": isOpen, onChange: handleFilter, value: content, autoComplete: "off", disabled: disabled, readOnly: readOnly, ...otherProps }, seedID('autocomplete-trigger')), _jsx(AnimatePresence, { children: visible && (_jsx("div", { ref: setTooltipRef, ...getTooltipProps({ className: styles.PopUp, style: { minInlineSize: triggerSize ? (triggerSize.width + 2) : 'auto' } }), children: _jsx(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
return (_jsxs("div", { ref: autocompleteRef, className: styles.Autocomplete, "data-focus-within": isFocusWithin, children: [_jsx(Textfield, { ref: setTriggerRef, id: seedID('autocomplete-trigger'), "aria-haspopup": "true", "aria-controls": seedID('autocomplete-menu'), "aria-expanded": isOpen, onChange: handleFilter, value: content, autoComplete: "off", disabled: disabled, readOnly: readOnly, ...otherProps }, seedID('autocomplete-trigger')), _jsx(AnimatePresence, { children: visible && (_jsx("div", { ref: setTooltipRef, ...getTooltipProps({ className: styles.PopUp, style: { minInlineSize: triggerSize ? (triggerSize.width + 2) : 'auto' } }), children: _jsx(LazyMotion, { features: domMax, strict: true, children: _jsx(m.div, { variants: AutocompleteAnimation, initial: "hidden", animate: "visible", exit: "hidden", children: _jsx(Menu, { role: "listbox", id: seedID('autocomplete-menu'), className: styles.OptionsList, style: dynamicStyle, "aria-labelledby": seedID('autocomplete-trigger'), children: filteredOptions.length === 0
|
|
75
|
+
? _jsx(Text, { as: "div", textAlign: "center", dimmed: 5, children: emptyMessage })
|
|
76
|
+
: Children.map(filteredOptions, (child) => isValidElement(child) && cloneElement(child, {
|
|
77
|
+
onClick: handleOptionClick
|
|
78
|
+
})) }) }) }) })) })] }));
|
|
79
79
|
});
|
|
80
80
|
Autocomplete.Option = AutocompleteOption;
|
|
81
81
|
Autocomplete.displayName = 'Autocomplete';
|
|
@@ -3,7 +3,7 @@ export declare type ContainerProps = {
|
|
|
3
3
|
/**
|
|
4
4
|
* Set the horizontal max-width of the container.
|
|
5
5
|
*/
|
|
6
|
-
dimension?: 'full' | 'medium' | 'large';
|
|
6
|
+
dimension?: 'full' | 'small' | 'medium' | 'large';
|
|
7
7
|
/**
|
|
8
8
|
* Set or remove the container's predefined horizontal padding.
|
|
9
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../src/components/container/container.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAI1C,oBAAY,cAAc,GAAG;IAC3B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../src/components/container/container.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAI1C,oBAAY,cAAc,GAAG;IAC3B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IAClD;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAA;AAED,aAAK,oBAAoB,GAAG,WAAW,CAAC,mBAAmB,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;AAEnF,eAAO,MAAM,SAAS,sBAmBI,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.Container{inline-size:100%;margin:0 auto;padding:0 .89rem}.Container[data-container-dimension=
|
|
1
|
+
.Container{inline-size:100%;margin:0 auto;padding:0 .89rem}.Container[data-container-dimension=small]{max-inline-size:35.56rem}@media (min-width:48em){.Container[data-container-dimension=small]{padding:0 1.78rem}}.Container[data-container-dimension=medium]{max-inline-size:55.56rem}@media (min-width:48em){.Container[data-container-dimension=medium]{padding:0 1.78rem}}.Container[data-container-dimension=large]{max-inline-size:80rem}@media (min-width:48em){.Container[data-container-dimension=large]{padding:0 1.78rem}}.Container[data-container-dimension=full]{max-inline-size:100%}@media (min-width:48em){.Container[data-container-dimension=full]{padding:0 1.78rem}}.Container[data-container-padding=false]{padding:0}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disclosure.d.ts","sourceRoot":"","sources":["../../../src/components/disclosure/disclosure.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,EACrB,SAAS,EACV,MAAM,OAAO,CAAA;AAMd,oBAAY,eAAe,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,GAAG;IACxE;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC;IACxC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAA;AAED,eAAO,MAAM,UAAU;IAnCrB;;OAEG;;IAEH;;;OAGG;aACM,SAAS;IAClB;;;;OAIG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;;OAGG;;
|
|
1
|
+
{"version":3,"file":"disclosure.d.ts","sourceRoot":"","sources":["../../../src/components/disclosure/disclosure.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,EACrB,SAAS,EACV,MAAM,OAAO,CAAA;AAMd,oBAAY,eAAe,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,GAAG;IACxE;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC;IACxC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAA;AAED,eAAO,MAAM,UAAU;IAnCrB;;OAEG;;IAEH;;;OAGG;aACM,SAAS;IAClB;;;;OAIG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;;OAGG;;sDAuGH,CAAA"}
|
|
@@ -3,7 +3,7 @@ import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import styles from './disclosure.module.css';
|
|
5
5
|
import { Text, Icon } from '../..';
|
|
6
|
-
import {
|
|
6
|
+
import { domMax, LazyMotion, m } from 'framer-motion';
|
|
7
7
|
export const Disclosure = forwardRef(({ children, open = false, padding = true, className, summary, contentMaxHeight, dimension = 'regular', iconPosition = 'left', expandable = true, style, ...otherProps }, forwardedRef) => {
|
|
8
8
|
const ref = useRef(forwardedRef);
|
|
9
9
|
const [isOpen, setIsOpen] = useState(open);
|
|
@@ -32,7 +32,7 @@ export const Disclosure = forwardRef(({ children, open = false, padding = true,
|
|
|
32
32
|
icon: 24
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
const renderContent = useCallback(() => (_jsx(
|
|
35
|
+
const renderContent = useCallback(() => (_jsx(LazyMotion, { features: domMax, children: _jsx(m.div, { className: styles.Content, "data-disclosure-padding": padding, "data-disclosure-height": Boolean(contentMaxHeight), animate: isOpen ? { y: 5, opacity: 1 } : { y: 0, opacity: 0 }, transition: { ease: 'easeOut', duration: 0.1 }, initial: false, children: children }) })), [children, contentMaxHeight, padding, isOpen]);
|
|
36
36
|
return (_jsxs("details", { style: { ...dynamicStyle, ...style }, className: clsx(styles.Disclosure, className), "data-disclosure-icon-position": iconPosition, "data-disclosure-dimension": dimension, "data-disclosure-expandable": expandable, onToggle: handleOpen(), "aria-expanded": isOpen ? 'true' : 'false', ref: ref, ...otherProps, children: [_jsxs(Text, { as: "summary", responsive: false, className: styles.Summary, "aria-expanded": isOpen, tabIndex: !expandable ? -1 : 0, size: dimension ? sizes[dimension].summary : undefined, weight: "bold", children: [summary, expandable && (_jsx(Icon, { className: styles.ExpandIcon, source: "chevron-right", dimension: sizes[dimension].icon }))] }), renderContent()] }));
|
|
37
37
|
});
|
|
38
38
|
Disclosure.displayName = 'Disclosure';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["../../../src/components/drawer/drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAQ/E,oBAAY,WAAW,GAAG,iBAAiB,CAAC,cAAc,CAAC,GAAG;IAC5D;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IAClC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACxB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAA;AAED,eAAO,MAAM,MAAM;;;IAzCjB;;;;;;OAMG;;IAEH;;;OAGG;YACK,SAAS;IACjB;;;;OAIG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;OAEG;;IAEH;;;;OAIG;;
|
|
1
|
+
{"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["../../../src/components/drawer/drawer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAQ/E,oBAAY,WAAW,GAAG,iBAAiB,CAAC,cAAc,CAAC,GAAG;IAC5D;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IAClC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACxB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAA;AAED,eAAO,MAAM,MAAM;;;IAzCjB;;;;;;OAMG;;IAEH;;;OAGG;YACK,SAAS;IACjB;;;;OAIG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;OAEG;;IAEH;;;;OAIG;;kDA8FH,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { domMax, LazyMotion, m } from 'framer-motion';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { FocusOn, AutoFocusInside } from 'react-focus-on';
|
|
6
6
|
import { useKeyPress } from 'ahooks';
|
|
@@ -28,6 +28,6 @@ export const Drawer = forwardRef(({ children, className, closeOnClickOutside = t
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
return (_jsx("div", { role: "dialog", "aria-modal": isModal, "data-theme": theme, "aria-labelledby": titleId, className: clsx(styles.Drawer, className), ref: forwardedRef, ...otherProps, children: _jsx(FocusOn, { enabled: isModal, onClickOutside: closeOnClickOutside ? onClose : undefined, onEscapeKey: onClose, children: _jsx(
|
|
31
|
+
return (_jsx("div", { role: "dialog", "aria-modal": isModal, "data-theme": theme, "aria-labelledby": titleId, className: clsx(styles.Drawer, className), ref: forwardedRef, ...otherProps, children: _jsx(FocusOn, { enabled: isModal, onClickOutside: closeOnClickOutside ? onClose : undefined, onEscapeKey: onClose, children: _jsx(LazyMotion, { features: domMax, children: _jsx(m.div, { variants: DrawerAnimation, initial: "hidden", animate: "visible", exit: "hidden", className: styles.Container, "data-drawer-side": side, children: _jsx(Elevator, { resting: 4, children: _jsxs("div", { className: styles.Content, style: dynamicStyle, ref: forwardedRef, ...otherProps, children: [(showHeader && title) && (_jsxs(Stack, { vAlign: "center", fill: false, hAlign: "space-between", direction: "row", className: styles.Header, children: [_jsx(Title, { responsive: false, level: "6", id: titleId, children: title }), onClose && _jsx(IconButton, { onClick: onClose, className: styles.CloseButton, icon: "xmark", kind: "flat" })] })), _jsx(AutoFocusInside, { children: children })] }) }) }) }) }) }));
|
|
32
32
|
});
|
|
33
33
|
Drawer.displayName = 'Drawer';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/modal/modal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAIrD,OAAO,EAAgB,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAIzE,oBAAY,UAAU,GAAG,iBAAiB,CAAC,cAAc,CAAC,GAAG;IAC3D;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAA;AAED,aAAK,cAAc,GAAG,KAAK,CAAC,yBAAyB,CAAC,UAAU,CAAC,GAAG;IAClE,OAAO,EAAE,KAAK,CAAC,yBAAyB,CAAC,iBAAiB,CAAC,CAAC;CAC7D,CAAA;AAqBD,eAAO,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"modal.d.ts","sourceRoot":"","sources":["../../../src/components/modal/modal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAIrD,OAAO,EAAgB,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAIzE,oBAAY,UAAU,GAAG,iBAAiB,CAAC,cAAc,CAAC,GAAG;IAC3D;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAA;AAED,aAAK,cAAc,GAAG,KAAK,CAAC,yBAAyB,CAAC,UAAU,CAAC,GAAG;IAClE,OAAO,EAAE,KAAK,CAAC,yBAAyB,CAAC,iBAAiB,CAAC,CAAC;CAC7D,CAAA;AAqBD,eAAO,MAAM,KAAK,gBAmCE,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { domMax, LazyMotion, m } from 'framer-motion';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
5
|
import { FocusOn } from 'react-focus-on';
|
|
6
6
|
import { ModalContent } from './content/modal-content';
|
|
@@ -26,7 +26,7 @@ const ModalAnimation = {
|
|
|
26
26
|
};
|
|
27
27
|
export const Modal = forwardRef(({ children, className, closeOnClickOutside = true, ...otherProps }, forwardedRef) => {
|
|
28
28
|
const { titleId, onClose } = useOverlayContext();
|
|
29
|
-
return (_jsx("div", { role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, className: clsx(styles.Modal, className), ref: forwardedRef, ...otherProps, children: _jsx(FocusOn, { onClickOutside: closeOnClickOutside ? onClose : undefined, onEscapeKey: onClose, children: _jsx(
|
|
29
|
+
return (_jsx("div", { role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, className: clsx(styles.Modal, className), ref: forwardedRef, ...otherProps, children: _jsx(FocusOn, { onClickOutside: closeOnClickOutside ? onClose : undefined, onEscapeKey: onClose, children: _jsx(LazyMotion, { features: domMax, children: _jsx(m.div, { variants: ModalAnimation, initial: "hidden", animate: "visible", exit: "hidden", className: styles.Container, children: children }) }) }) }));
|
|
30
30
|
});
|
|
31
31
|
Modal.displayName = 'Modal';
|
|
32
32
|
Modal.Content = ModalContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay-container.d.ts","sourceRoot":"","sources":["../../../src/components/overlay-container/overlay-container.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAA;AAM5C,oBAAY,qBAAqB,GAAG;IAClC;;;;OAIG;IACH,QAAQ,EAAE,SAAS,CAAA;IACnB;;OAEG;IACH,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IACzC;;OAEG;IACH,OAAO,CAAC,IAAI,IAAI,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"overlay-container.d.ts","sourceRoot":"","sources":["../../../src/components/overlay-container/overlay-container.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAa,MAAM,OAAO,CAAA;AAM5C,oBAAY,qBAAqB,GAAG;IAClC;;;;OAIG;IACH,QAAQ,EAAE,SAAS,CAAA;IACnB;;OAEG;IACH,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;IACzC;;OAEG;IACH,OAAO,CAAC,IAAI,IAAI,CAAC;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA8C5D,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { domMax, LazyMotion, m, AnimatePresence } from 'framer-motion';
|
|
3
3
|
import { useEffect } from 'react';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
5
|
import { useUIDSeed } from 'react-uid';
|
|
@@ -12,6 +12,6 @@ export const OverlayContainer = ({ children, root = document.body, overlayColor
|
|
|
12
12
|
throw new Error('An OverlayContainer must not be inside another container. Please change the root prop.');
|
|
13
13
|
}
|
|
14
14
|
}, [root]);
|
|
15
|
-
const content = (_jsx(OverlayProvider, { onClose: onClose, children: _jsx(AnimatePresence, { exitBeforeEnter: true, children: children && (
|
|
15
|
+
const content = (_jsx(OverlayProvider, { onClose: onClose, children: _jsx(AnimatePresence, { exitBeforeEnter: true, children: children && (_jsx("div", { "data-overlay-container": true, "data-overlay-container-obfuscate": obfuscate, className: styles.OverlayContainer, style: { zIndex: index }, children: _jsxs(LazyMotion, { features: domMax, children: [obfuscate && (_jsx(m.span, { className: styles.Backdrop, "data-overlay-color": overlayColor, initial: { opacity: 0 }, animate: { opacity: 0.95 }, transition: { duration: 0.2 }, exit: { opacity: 0 } }, seedID('modal-backdrop'))), children] }) })) }) }));
|
|
16
16
|
return createPortal(content, root);
|
|
17
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../../src/components/popover/popover.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EASV,MAAM,OAAO,CAAA;AAId,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAY,MAAM,gBAAgB,CAAA;AAK3F,oBAAY,YAAY,GAAG,cAAc,GAAG;IAC1C;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,aAAa,GAAG,aAAa,GAAG,kBAAkB,CAAC;IAC/D;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAA;AAqBD,eAAO,MAAM,OAAO;IAjElB;;OAEG;cACO,SAAS;IACnB;;OAEG;aACM,SAAS;IAClB;;OAEG;;IAEH;;;;;;;;OAQG;;IAEH;;OAEG;;IAEH;;;OAGG;2BACmB,OAAO,KAAK,IAAI;IACtC;;;OAGG;;IAEH;;OAEG;;IAEH;;OAEG;;
|
|
1
|
+
{"version":3,"file":"popover.d.ts","sourceRoot":"","sources":["../../../src/components/popover/popover.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EASV,MAAM,OAAO,CAAA;AAId,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAY,MAAM,gBAAgB,CAAA;AAK3F,oBAAY,YAAY,GAAG,cAAc,GAAG;IAC1C;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,aAAa,GAAG,aAAa,GAAG,kBAAkB,CAAC;IAC/D;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAA;AAqBD,eAAO,MAAM,OAAO;IAjElB;;OAEG;cACO,SAAS;IACnB;;OAEG;aACM,SAAS;IAClB;;OAEG;;IAEH;;;;;;;;OAQG;;IAEH;;OAEG;;IAEH;;;OAGG;2BACmB,OAAO,KAAK,IAAI;IACtC;;;OAGG;;IAEH;;OAEG;;IAEH;;OAEG;;kDAkJH,CAAA"}
|
|
@@ -4,7 +4,7 @@ import { useKeyPress, useFocusWithin } from 'ahooks';
|
|
|
4
4
|
import styles from './popover.module.css';
|
|
5
5
|
import { useUIDSeed } from 'react-uid';
|
|
6
6
|
import { usePopperTooltip } from 'react-popper-tooltip';
|
|
7
|
-
import {
|
|
7
|
+
import { domMax, LazyMotion, m, AnimatePresence } from 'framer-motion';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
9
|
const PopoverAnimation = {
|
|
10
10
|
visible: {
|
|
@@ -82,12 +82,12 @@ export const Popover = forwardRef(({ children, trigger, offset = 8, placement =
|
|
|
82
82
|
id: seedID('popover-trigger'),
|
|
83
83
|
key: seedID('popover-trigger'),
|
|
84
84
|
'aria-haspopup': 'true',
|
|
85
|
-
'aria-controls': seedID('popover-
|
|
85
|
+
'aria-controls': seedID('popover-dialog'),
|
|
86
86
|
'aria-expanded': isOpen,
|
|
87
87
|
...otherProps
|
|
88
|
-
})), _jsx(AnimatePresence, { children: visible && (_jsx("div", { ref: setTooltipRef, role: "tooltip", id: seedID('tooltip-content'), ...getTooltipProps({ className: styles.PopUp }), children: _jsx(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
})), _jsx(AnimatePresence, { children: visible && (_jsx("div", { ref: setTooltipRef, role: "tooltip", id: seedID('tooltip-content'), ...getTooltipProps({ className: styles.PopUp }), children: _jsx(LazyMotion, { features: domMax, children: _jsx(m.div, { variants: PopoverAnimation, initial: "hidden", animate: "visible", exit: "hidden", children: Children.map(children, (child) => isValidElement(child) && cloneElement(child, {
|
|
89
|
+
id: seedID('popover-dialog'),
|
|
90
|
+
'aria-labelledby': seedID('popover-trigger')
|
|
91
|
+
})) }) }) }, seedID('tooltip-content'))) })] }));
|
|
92
92
|
});
|
|
93
93
|
Popover.displayName = 'Popover';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../../src/components/spinner/spinner.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,aAAa,EAAE,MAAM,OAAO,CAAA;AAIjD,oBAAY,YAAY,GAAG,aAAa,CAAC,UAAU,CAAC,GAAG;IACrD;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC;IACxC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAA;AAED,eAAO,MAAM,OAAO;IAVlB;;OAEG;;IAEH;;OAEG;;
|
|
1
|
+
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../../src/components/spinner/spinner.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,aAAa,EAAE,MAAM,OAAO,CAAA;AAIjD,oBAAY,YAAY,GAAG,aAAa,CAAC,UAAU,CAAC,GAAG;IACrD;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC;IACxC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAA;AAED,eAAO,MAAM,OAAO;IAVlB;;OAEG;;IAEH;;OAEG;;iDA8DH,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
import clsx from 'clsx';
|
|
4
|
-
import {
|
|
4
|
+
import { domMax, LazyMotion, m } from 'framer-motion';
|
|
5
5
|
export const Spinner = forwardRef(({ className, style, color, dimension = 'big' }, forwardedRef) => {
|
|
6
6
|
const attributes = {
|
|
7
7
|
small: {
|
|
@@ -14,10 +14,10 @@ export const Spinner = forwardRef(({ className, style, color, dimension = 'big'
|
|
|
14
14
|
size: 30
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
-
return (_jsx(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
return (_jsx(LazyMotion, { features: domMax, strict: true, children: _jsx(m.svg, { ref: forwardedRef, className: clsx(className), animate: { rotate: '2turn' }, transition: {
|
|
18
|
+
duration: 2,
|
|
19
|
+
repeat: Infinity,
|
|
20
|
+
repeatDelay: 2
|
|
21
|
+
}, style: { ...style, originX: '50%', originY: '50%' }, width: attributes[dimension].size, height: attributes[dimension].size, viewBox: "0 0 38 38", stroke: color || 'currentColor', xmlns: "http://www.w3.org/2000/svg", strokeLinecap: "round", children: _jsxs("g", { transform: "translate(1 1)", strokeWidth: 2, fill: "none", fillRule: "evenodd", children: [_jsx("circle", { strokeOpacity: 0.5, cx: 18, cy: 18, r: 18 }), _jsx("path", { d: "M36 18c0-9.94-8.06-18-18-18", children: _jsx("animateTransform", { attributeName: "transform", type: "rotate", from: "0 18 18", to: "360 18 18", dur: "1s", repeatCount: "indefinite" }) })] }) }) }));
|
|
22
22
|
});
|
|
23
23
|
Spinner.displayName = 'Spinner';
|
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { TabPanelProps } from './tab-panel';
|
|
5
|
-
import { Polymorphic } from '../..';
|
|
6
|
-
/**
|
|
7
|
-
* Tab.Root
|
|
8
|
-
* Public api
|
|
9
|
-
*/
|
|
10
|
-
export declare type TabProps = PropsWithClass & {
|
|
1
|
+
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
export declare type TabProps = PropsWithChildren<PropsWithClass> & {
|
|
11
4
|
/**
|
|
12
|
-
*
|
|
5
|
+
* The value for the selected tab, if controlled
|
|
13
6
|
*/
|
|
14
|
-
|
|
7
|
+
value?: TabsPrimitive.TabsProps['value'];
|
|
15
8
|
/**
|
|
16
|
-
*
|
|
9
|
+
* The value of the tab to select by default, if uncontrolled
|
|
17
10
|
*/
|
|
18
|
-
|
|
11
|
+
defaultValue?: TabsPrimitive.TabsProps['defaultValue'];
|
|
19
12
|
/**
|
|
20
|
-
*
|
|
13
|
+
* A function called when a new tab is selected
|
|
21
14
|
*/
|
|
22
|
-
|
|
15
|
+
onValueChange?: TabsPrimitive.TabsProps['onValueChange'];
|
|
16
|
+
/**
|
|
17
|
+
* The direction of navigation between toolbar items.
|
|
18
|
+
* @defaultValue ltr
|
|
19
|
+
*/
|
|
20
|
+
dir?: TabsPrimitive.TabsProps['dir'];
|
|
21
|
+
/**
|
|
22
|
+
* When `automatic`, tabs are activated when receiving focus.
|
|
23
|
+
* When `manual`, tabs are activated when clicked.
|
|
24
|
+
*/
|
|
25
|
+
activationMode?: TabsPrimitive.TabsProps['activationMode'];
|
|
26
|
+
/**
|
|
27
|
+
* When true, keyboard navigation will loop from last tab to first, and vice versa.
|
|
28
|
+
* @defaultValue true
|
|
29
|
+
*/
|
|
30
|
+
loop?: TabsPrimitive.TabsListProps['loop'];
|
|
23
31
|
};
|
|
24
|
-
declare
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
List: React.ForwardRefExoticComponent<TabListProps>;
|
|
32
|
+
export declare const Tab: {
|
|
33
|
+
({ className, children, onValueChange, defaultValue, loop, ...otherProps }: TabProps): JSX.Element;
|
|
34
|
+
Panel: ({ children, label, ...otherProps }: import("./tabs-panel").TabPanelProps) => JSX.Element;
|
|
28
35
|
};
|
|
29
|
-
/**
|
|
30
|
-
* Tab.Root
|
|
31
|
-
* Component
|
|
32
|
-
*/
|
|
33
|
-
export declare const Tab: TabComponent;
|
|
34
|
-
export {};
|
|
35
36
|
//# sourceMappingURL=tab.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab.d.ts","sourceRoot":"","sources":["../../../src/components/tab/tab.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"tab.d.ts","sourceRoot":"","sources":["../../../src/components/tab/tab.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,sBAAsB,CAAA;AAErD,OAAO,EACqB,iBAAiB,EAC5C,MAAM,OAAO,CAAA;AAQd,oBAAY,QAAQ,GAAG,iBAAiB,CAAC,cAAc,CAAC,GAAG;IACzD;;OAEG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACzC;;OAEG;IACH,YAAY,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACvD;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IACzD;;;OAGG;IACH,GAAG,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACrC;;;OAGG;IACH,cAAc,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAC3D;;;OAGG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;CAC5C,CAAC;AAEF,eAAO,MAAM,GAAG;gFAOb,QAAQ;;CAuCV,CAAA"}
|
|
@@ -1,35 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { TabList } from './tab-list';
|
|
7
|
-
import { TabPanel } from './tab-panel';
|
|
8
|
-
import { Tabs as TabsWrapper } from './primitive-tab';
|
|
2
|
+
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
3
|
+
import { domMax, LazyMotion, m } from 'framer-motion';
|
|
4
|
+
import { Children, isValidElement, useCallback, useState } from 'react';
|
|
5
|
+
import { Button } from '../..';
|
|
9
6
|
import styles from './tab.module.css';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
onChange(currentTab);
|
|
22
|
-
}
|
|
23
|
-
}, [currentTab, onChange]);
|
|
24
|
-
return (_jsx("div", { ref: forwardedRef, className: clsx(styles.Tab, className), ...otherProps, children: _jsxs(TabsWrapper, { state: tabState, children: [_jsx(TabList, { children: Children.map(children, (child, index) => isValidElement(child) && (_jsx(TabItem, { id: seedID('tab-item'), "aria-controls": seedID('tab-panel'), icon: child.props.icon, children: child.props.label }))) }), Children.map(children, (child, index) => isValidElement(child) && cloneElement(child, {
|
|
25
|
-
id: seedID('tab-panel'),
|
|
26
|
-
'aria-labelledby': seedID('tab-item')
|
|
27
|
-
}))] }) }));
|
|
28
|
-
});
|
|
29
|
-
Tab.displayName = 'Tab';
|
|
30
|
-
/* -------------------------------------------------------------------------- */
|
|
31
|
-
/* Export */
|
|
32
|
-
/* -------------------------------------------------------------------------- */
|
|
7
|
+
import { TabPanel } from './tabs-panel';
|
|
8
|
+
import { useUIDSeed } from 'react-uid';
|
|
9
|
+
export const Tab = ({ className, children, onValueChange, defaultValue, loop, ...otherProps }) => {
|
|
10
|
+
const [activeItem, setActiveItem] = useState(defaultValue ?? '');
|
|
11
|
+
const uid = useUIDSeed();
|
|
12
|
+
const handleOnVlaueChange = useCallback((value) => {
|
|
13
|
+
onValueChange?.(value);
|
|
14
|
+
setActiveItem(value);
|
|
15
|
+
}, [onValueChange]);
|
|
16
|
+
return (_jsxs(TabsPrimitive.Root, { defaultValue: defaultValue, onValueChange: handleOnVlaueChange, ...otherProps, children: [_jsx(LazyMotion, { features: domMax, strict: true, children: _jsx(TabsPrimitive.List, { className: styles.List, loop: loop, children: Children.map(children, child => isValidElement(child) && (_jsx(TabsPrimitive.Trigger, { value: child.props.value, disabled: child.props.disabled, className: styles.Trigger, asChild: true, children: _jsxs(Button, { kind: "flat", icon: child.props.icon, children: [child.props.label, (child.props.value === activeItem) && 'active' && (_jsx(m.span, { className: styles.Highlight, layoutId: uid('tab-highlight') }))] }) }))) }) }), children] }));
|
|
17
|
+
};
|
|
33
18
|
Tab.Panel = TabPanel;
|
|
34
|
-
Tab.Item = TabItem;
|
|
35
|
-
Tab.List = TabList;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
.List{--separator-size:2px;border-bottom:var(--separator-size) solid var(--dimmed-1)}.Trigger{-webkit-appearance:none;appearance:none;background:none;background-color:transparent;block-size:2.67rem;border:0;border-radius:0;color:var(--dimmed-6);flex-shrink:0;font-family:inherit;font-size:inherit;font-weight:token(--font-weight-semi-bold);outline-offset:calc(var(--separator-size)*-1);overflow:unset;padding:.44rem .89rem;position:relative;white-space:nowrap}.Trigger,.Trigger:not([aria-disabled=true]){-webkit-backdrop-filter:none;backdrop-filter:none}.Trigger:not([aria-disabled=true]){color:var(--dimmed-5)}.Trigger.Trigger:not([aria-disabled=true]):is(:hover,:focus,:active){-webkit-backdrop-filter:none;backdrop-filter:none;background:none;color:var(--global-foreground)}.Trigger.Trigger[aria-disabled=true]{-webkit-backdrop-filter:none;backdrop-filter:none;background:none}.Trigger[data-state=active]{-webkit-text-stroke:.4px var(--global-foreground);color:var(--global-foreground)}.Highlight{background:var(--cta-default);border-radius:2px 2px 0 0;bottom:calc(var(--separator-size)*-1);height:4px;pointer-events:none;position:absolute;width:100%}.Panel{animation:fade-in .2s;animation-timing-function:cubic-bezier(0,0,.34,1))}@keyframes fade-in{0%{opacity:0;transform:translate(var(--fade-from-x,0),var(--fade-from-y,0))}to{opacity:unset;transform:none}}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
2
|
+
import { IconProps } from '../..';
|
|
3
|
+
import { PropsWithChildren } from 'react';
|
|
4
|
+
export declare type TabPanelProps = PropsWithChildren<PropsWithClass> & {
|
|
5
|
+
label: string;
|
|
6
|
+
icon?: IconProps['source'];
|
|
7
|
+
value: TabsPrimitive.TabsContentProps['value'];
|
|
8
|
+
};
|
|
9
|
+
export declare const TabPanel: ({ children, label, ...otherProps }: TabPanelProps) => JSX.Element;
|
|
10
|
+
//# sourceMappingURL=tabs-panel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs-panel.d.ts","sourceRoot":"","sources":["../../../src/components/tab/tabs-panel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAGxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAEzC,oBAAY,aAAa,GAAG,iBAAiB,CAAC,cAAc,CAAC,GAAG;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC3B,KAAK,EAAE,aAAa,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;CAChD,CAAC;AAEF,eAAO,MAAM,QAAQ,uCAIlB,aAAa,gBAQf,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
3
|
+
import styles from './tab.module.css';
|
|
4
|
+
export const TabPanel = ({ children, label, ...otherProps }) => (_jsx(TabsPrimitive.Content, { className: styles.Panel, "data-tabs-label": label, ...otherProps, children: children }));
|
|
@@ -3,7 +3,7 @@ import { useCallback, useMemo } from 'react';
|
|
|
3
3
|
import { Button, Menu, Popover } from '../../..';
|
|
4
4
|
export const ToggleColumnsControl = ({ columns, visibleColumns }) => {
|
|
5
5
|
const someVisibleColums = useMemo(() => visibleColumns.length !== 0, [visibleColumns]);
|
|
6
|
-
const filteredColumns = useMemo(() => columns.filter(col => !col.
|
|
6
|
+
const filteredColumns = useMemo(() => columns.filter(col => !col.isToggable), [columns]);
|
|
7
7
|
const handleToggleAll = useCallback(() => {
|
|
8
8
|
/**
|
|
9
9
|
* If there are visible columns (excluding artificial ones),
|
|
@@ -19,5 +19,5 @@ export const ToggleColumnsControl = ({ columns, visibleColumns }) => {
|
|
|
19
19
|
*/
|
|
20
20
|
filteredColumns.forEach(col => col.toggleHidden(false));
|
|
21
21
|
}, [someVisibleColums, filteredColumns, visibleColumns]);
|
|
22
|
-
return (_jsx(Popover, { placement: "bottom-start", trigger: _jsx(Button, { kind: "secondary", children: "Toggle columns" }), children: _jsxs(Menu, { children: [_jsx(Menu.ItemCheckbox, { onClick: () => handleToggleAll(), checked: true, icon: visibleColumns.length === 0 ? 'check' : 'minus', children: "Toggle All" }), columns.filter(col => !col.
|
|
22
|
+
return (_jsx(Popover, { placement: "bottom-start", trigger: _jsx(Button, { kind: "secondary", children: "Toggle columns" }), children: _jsxs(Menu, { children: [_jsx(Menu.ItemCheckbox, { onClick: () => handleToggleAll(), checked: true, icon: visibleColumns.length === 0 ? 'check' : 'minus', children: "Toggle All" }), columns.filter(col => !col.isToggable).map((column, i) => (_jsx(Menu.ItemCheckbox, { autoFocus: i === 0, checked: column.isVisible, icon: column.isVisible ? 'check' : undefined, onClick: () => column.toggleHidden(), children: column.render('Header') }, column.id)))] }) }));
|
|
23
23
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ComponentType, ReactNode } from 'react';
|
|
2
|
-
import { IdType,
|
|
2
|
+
import { IdType, SortingRule } from 'react-table';
|
|
3
3
|
import { TableHeaderProps } from './table-header';
|
|
4
4
|
import { TablePaginationProps } from './table-pagination';
|
|
5
|
-
import { CustomColumnsType,
|
|
5
|
+
import { CustomColumnsType, OptionalDataTypes, CustomSortingRule, PaginationPageType } from './types';
|
|
6
6
|
export declare type TableProps<T extends Record<string, unknown>> = PropsWithClass & {
|
|
7
7
|
/**
|
|
8
8
|
* Define the columns and headers of the table.
|
|
@@ -16,51 +16,11 @@ export declare type TableProps<T extends Record<string, unknown>> = PropsWithCla
|
|
|
16
16
|
* Define the default visibility of the columns. This is an array of columns `id`,
|
|
17
17
|
*/
|
|
18
18
|
defaultHiddenColumns?: Array<IdType<T>>;
|
|
19
|
-
/**
|
|
20
|
-
* Show pagination below the table. This is recommended only for tables with a lot of rows.
|
|
21
|
-
*/
|
|
22
|
-
showPagination?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* The amount of entries to show for each page.
|
|
25
|
-
*/
|
|
26
|
-
itemsPerPage?: number;
|
|
27
|
-
/**
|
|
28
|
-
* The index of the page that should be set as active when the table is rendered.
|
|
29
|
-
*/
|
|
30
|
-
activePageIndex?: number;
|
|
31
|
-
/**
|
|
32
|
-
* The callback that is called when the active page index and page size change.
|
|
33
|
-
* Passing this property along side `showPagination` will enable manual pagination,
|
|
34
|
-
* disabling the automatic one.
|
|
35
|
-
*/
|
|
36
|
-
onDataUpdate?: ({ pageIndex, pageSize }: PaginationType) => Promise<void> | void;
|
|
37
|
-
/**
|
|
38
|
-
* Set the number of pages to show in the pagination. Used only when doing manual pagination.
|
|
39
|
-
*/
|
|
40
|
-
totalRows?: number;
|
|
41
|
-
/**
|
|
42
|
-
* Set clusters of items to show in a single page. These values are used to
|
|
43
|
-
* compute the select options for the page size select.
|
|
44
|
-
*/
|
|
45
|
-
pageClusters?: TablePaginationProps['clusters'];
|
|
46
19
|
/**
|
|
47
20
|
* Enable row selection. This property will render an additiona column
|
|
48
21
|
* at the start of the table, containing a checkbox.
|
|
49
22
|
*/
|
|
50
23
|
selectableRows?: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Callback run when the selected rows change
|
|
53
|
-
*/
|
|
54
|
-
onSelectionChange?: (selectedRows?: Array<Row<T>>, selectedRowIds?: Record<IdType<T>, boolean>) => void;
|
|
55
|
-
/**
|
|
56
|
-
* If true, disable the automatic column sorting of the table. Turn this on if you want to
|
|
57
|
-
* to control the sorting yourself.
|
|
58
|
-
*/
|
|
59
|
-
isManualSorted?: boolean;
|
|
60
|
-
/**
|
|
61
|
-
* Callback run when a column is sorted
|
|
62
|
-
*/
|
|
63
|
-
onSortChange?: (sorting: Array<CustomSortingRule<T>>) => void;
|
|
64
24
|
/**
|
|
65
25
|
* Add an alternate style to the table rows
|
|
66
26
|
*/
|
|
@@ -97,11 +57,11 @@ export declare type TableProps<T extends Record<string, unknown>> = PropsWithCla
|
|
|
97
57
|
/**
|
|
98
58
|
* Set the label for selected items in the table. Default to "Selected items"
|
|
99
59
|
*/
|
|
100
|
-
selectedLabel?: (
|
|
60
|
+
selectedLabel?: (selectedRowIds: Array<IdType<T>>) => ReactNode;
|
|
101
61
|
/**
|
|
102
62
|
* Pass custom components to show when rows are selected.
|
|
103
63
|
*/
|
|
104
|
-
selectedActions?: ReactNode;
|
|
64
|
+
selectedActions?: (selectedRowIds: Array<IdType<T>>) => ReactNode;
|
|
105
65
|
/**
|
|
106
66
|
* Set the table height after which the table will scroll.
|
|
107
67
|
*/
|
|
@@ -118,21 +78,51 @@ export declare type TableProps<T extends Record<string, unknown>> = PropsWithCla
|
|
|
118
78
|
* a component.
|
|
119
79
|
*/
|
|
120
80
|
expandableRowComponent?: ComponentType<T>;
|
|
121
|
-
/**
|
|
122
|
-
* A react component that add custom actions to rows. If fuction is passed,
|
|
123
|
-
* the function will be called with the row data and the function must return
|
|
124
|
-
* a component.
|
|
125
|
-
*/
|
|
126
|
-
actionsRowComponent?: ComponentType<Row<T>>;
|
|
127
81
|
/**
|
|
128
82
|
* Custom component/empty state to show when the table has no data or
|
|
129
83
|
* all columns have been toggled off.
|
|
130
84
|
*/
|
|
131
85
|
emptyComponent?: ReactNode;
|
|
132
86
|
/**
|
|
133
|
-
*
|
|
87
|
+
* Show pagination below the table. This is recommended only for tables with a lot of rows.
|
|
88
|
+
*/
|
|
89
|
+
showPagination?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* The index of the page that should be set as active when the table is rendered.
|
|
92
|
+
*/
|
|
93
|
+
initialPageIndex?: number;
|
|
94
|
+
/**
|
|
95
|
+
* The amount of entries to show for each page.
|
|
96
|
+
*/
|
|
97
|
+
itemsPerPage?: number;
|
|
98
|
+
/**
|
|
99
|
+
* Set the number of pages to show in the pagination. Used only when doing manual pagination.
|
|
134
100
|
*/
|
|
101
|
+
totalRows?: number;
|
|
102
|
+
/**
|
|
103
|
+
* Set clusters of items to show in a single page. These values are used to
|
|
104
|
+
* compute the select options for the page size select.
|
|
105
|
+
*/
|
|
106
|
+
pageClusters?: TablePaginationProps['clusters'];
|
|
107
|
+
/**
|
|
108
|
+
* The callback that is called when the active page index and page size change.
|
|
109
|
+
* Passing this property will enable manual pagination,
|
|
110
|
+
* disabling the automatic one.
|
|
111
|
+
*/
|
|
112
|
+
onPaginationChange?: ({ pageIndex, pageSize }: PaginationPageType) => Promise<void> | void;
|
|
113
|
+
/**
|
|
114
|
+
* If true, disable the automatic column sorting of the table. Turn this on if you want to
|
|
115
|
+
* to control the sorting yourself.
|
|
116
|
+
*/
|
|
117
|
+
isManualSorted?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Set the initial sorted column and order by passing column id and order.
|
|
120
|
+
*/
|
|
135
121
|
initialSortBy?: Array<SortingRule<T>>;
|
|
122
|
+
/**
|
|
123
|
+
* Callback run when a column is sorted
|
|
124
|
+
*/
|
|
125
|
+
onSortChange?: (sorting: Array<CustomSortingRule<T>>) => void;
|
|
136
126
|
};
|
|
137
|
-
export declare const Table: <T extends Record<string, unknown>>({ className, style, columns, data, selectableRows,
|
|
127
|
+
export declare const Table: <T extends Record<string, unknown>>({ className, style, columns, data, selectableRows, stripes, showSeparators, title, actions, selectedActions, selectedLabel, showHeader, showTableHead, columnsControl, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage, totalRows, initialPageIndex, onPaginationChange, onSortChange, pageClusters, initialSortBy, ...otherProps }: TableProps<T>) => JSX.Element;
|
|
138
128
|
//# sourceMappingURL=table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/components/table/table.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EAA2B,SAAS,EAClD,MAAM,OAAO,CAAA;AACd,OAAO,EACE,MAAM,
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../../src/components/table/table.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EAA2B,SAAS,EAClD,MAAM,OAAO,CAAA;AACd,OAAO,EACE,MAAM,EAEsB,WAAW,EAC/C,MAAM,aAAa,CAAA;AAcpB,OAAO,EAAe,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAC9D,OAAO,EAAmB,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAE1E,OAAO,EAC+B,iBAAiB,EACpC,iBAAiB,EAAE,iBAAiB,EAAE,kBAAkB,EAC1E,MAAM,SAAS,CAAA;AAEhB,oBAAY,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,cAAc,GAAG;IAC3E;;OAEG;IACH,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAC9B;;OAEG;IACH,IAAI,EAAE,KAAK,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC;;OAEG;IACH,oBAAoB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;IAC/D;;MAEE;IACH,eAAe,CAAC,EAAE,CAAC,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;IAClE;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAC1C;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACJ,YAAY,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACJ,SAAS,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACJ,YAAY,CAAC,EAAE,oBAAoB,CAAC,UAAU,CAAC,CAAC;IAC/C;;;;OAIG;IACJ,kBAAkB,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,kBAAkB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC3F;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACxB;;MAEE;IACH,aAAa,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC;;OAEG;IACJ,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;CAC/D,CAAA;AAED,eAAO,MAAM,KAAK,geAwVjB,CAAA"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import {
|
|
4
|
-
import { Fragment,
|
|
3
|
+
import { domMax, LazyMotion, m, AnimatePresence } from 'framer-motion';
|
|
4
|
+
import { Fragment, useCallback, useMemo } from 'react';
|
|
5
5
|
import { useExpanded, usePagination, useRowSelect, useSortBy, useTable } from 'react-table';
|
|
6
6
|
import { useUIDSeed } from 'react-uid';
|
|
7
|
+
import { useUpdateEffect } from 'ahooks';
|
|
7
8
|
import { Skeleton, Stack, Text, ToggleButton } from '../..';
|
|
8
9
|
import styles from './table.module.css';
|
|
9
10
|
import { TableCell } from './table-cell';
|
|
@@ -13,21 +14,33 @@ import { TableExpand } from './table-expand';
|
|
|
13
14
|
import { TableHeader } from './table-header';
|
|
14
15
|
import { TablePagination } from './table-pagination';
|
|
15
16
|
import { TableRow } from './table-row';
|
|
16
|
-
export const Table = ({ className, style, columns, data = [], selectableRows,
|
|
17
|
+
export const Table = ({ className, style, columns, data = [], selectableRows, stripes, showSeparators = true, title, actions, selectedActions, selectedLabel = selectedRows => `Selected items: ${selectedRows.length}`, showHeader = false, showTableHead = true, columnsControl = false, defaultHiddenColumns, height, loading, background, expandableRowComponent, emptyComponent, showPagination, isManualSorted, itemsPerPage = 10, totalRows, initialPageIndex = 0, onPaginationChange, onSortChange, pageClusters, initialSortBy = [], ...otherProps }) => {
|
|
17
18
|
const uid = useUIDSeed();
|
|
18
19
|
const hasSomeExpandableRows = useMemo(() => data.some(d => d.subRows), [data]);
|
|
19
|
-
const isManualPaginated = useMemo(() => Boolean(
|
|
20
|
+
const isManualPaginated = useMemo(() => Boolean(showPagination && onPaginationChange && totalRows), [showPagination, totalRows, onPaginationChange]);
|
|
21
|
+
const manualPaginationPageCount = useMemo(() => (isManualPaginated && totalRows) ? Math.ceil(totalRows / itemsPerPage) : -1, [isManualPaginated, totalRows, itemsPerPage]);
|
|
22
|
+
const getHiddenColumns = useCallback(() => {
|
|
23
|
+
const hiddenColumns = defaultHiddenColumns ? [...defaultHiddenColumns] : [];
|
|
24
|
+
if (!selectableRows)
|
|
25
|
+
hiddenColumns.push('selection');
|
|
26
|
+
if (!hasSomeExpandableRows)
|
|
27
|
+
hiddenColumns.push('expander');
|
|
28
|
+
return hiddenColumns;
|
|
29
|
+
}, [defaultHiddenColumns, selectableRows, hasSomeExpandableRows]);
|
|
30
|
+
const getRowId = useCallback((originalRow, relativeIndex, parent) => originalRow?._id || (parent && [parent.id, relativeIndex].join('.')) || relativeIndex.toString(), []);
|
|
20
31
|
const { getTableProps, getTableBodyProps, headerGroups, rows, page, pageCount, gotoPage, allColumns, prepareRow, selectedFlatRows, visibleColumns, setPageSize, setHiddenColumns, state: { pageSize, pageIndex, selectedRowIds, sortBy } } = useTable({
|
|
21
32
|
columns,
|
|
22
33
|
data,
|
|
34
|
+
getRowId,
|
|
35
|
+
expandSubRows: Boolean(!expandableRowComponent),
|
|
36
|
+
manualPagination: isManualPaginated,
|
|
37
|
+
pageCount: manualPaginationPageCount,
|
|
23
38
|
manualSortBy: isManualSorted,
|
|
24
39
|
disableMultiSort: true,
|
|
25
|
-
expandSubRows: Boolean(!expandableRowComponent),
|
|
26
40
|
autoResetHiddenColumns: false,
|
|
27
41
|
autoResetPage: false,
|
|
28
|
-
|
|
42
|
+
autoResetSortBy: false,
|
|
29
43
|
autoResetSelectedRows: false,
|
|
30
|
-
pageCount: (isManualPaginated && totalRows) ? Math.ceil(totalRows / itemsPerPage) : 10,
|
|
31
44
|
/**
|
|
32
45
|
* This `paginateExpandedRows` prop prevent expanded rows to
|
|
33
46
|
* be placed in the next page. But it breaks row selection
|
|
@@ -35,21 +48,21 @@ export const Table = ({ className, style, columns, data = [], selectableRows, on
|
|
|
35
48
|
*/
|
|
36
49
|
initialState: {
|
|
37
50
|
sortBy: initialSortBy,
|
|
38
|
-
pageIndex:
|
|
39
|
-
pageSize: showPagination ? itemsPerPage :
|
|
40
|
-
hiddenColumns:
|
|
51
|
+
pageIndex: initialPageIndex,
|
|
52
|
+
pageSize: showPagination ? itemsPerPage : data.length,
|
|
53
|
+
hiddenColumns: getHiddenColumns()
|
|
41
54
|
}
|
|
42
55
|
}, useSortBy, useExpanded, usePagination, useRowSelect, (hooks) => {
|
|
43
56
|
const checkboxColumn = [{
|
|
44
57
|
id: 'selection',
|
|
45
58
|
isCollapsed: true,
|
|
46
|
-
|
|
47
|
-
Header: ({
|
|
59
|
+
isToggable: true,
|
|
60
|
+
Header: ({ getToggleAllPageRowsSelectedProps }) => (!loading ? _jsx(TableCheckbox, { ...getToggleAllPageRowsSelectedProps() }) : null),
|
|
48
61
|
Cell: ({ row }) => _jsx(TableCheckbox, { ...row.getToggleRowSelectedProps() })
|
|
49
62
|
}];
|
|
50
63
|
const expanderColumn = [{
|
|
51
64
|
id: 'expander',
|
|
52
|
-
|
|
65
|
+
isToggable: true,
|
|
53
66
|
expander: true,
|
|
54
67
|
minWidth: 40,
|
|
55
68
|
align: 'center',
|
|
@@ -61,75 +74,58 @@ export const Table = ({ className, style, columns, data = [], selectableRows, on
|
|
|
61
74
|
} }))
|
|
62
75
|
: null)
|
|
63
76
|
}];
|
|
64
|
-
const actionsColumn = [{
|
|
65
|
-
id: 'actions',
|
|
66
|
-
isCollapsed: true,
|
|
67
|
-
hideFromList: true,
|
|
68
|
-
Cell: ({ row }) => (ActionsRowComponent ? _jsx(ActionsRowComponent, { ...row }) : null)
|
|
69
|
-
}];
|
|
70
77
|
hooks.visibleColumns.push(columns => [
|
|
71
78
|
...checkboxColumn,
|
|
72
79
|
...expanderColumn,
|
|
73
|
-
...actionsColumn,
|
|
74
80
|
...columns
|
|
75
81
|
]);
|
|
76
82
|
});
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
artificialColumns.push('selection');
|
|
81
|
-
if (!hasSomeExpandableRows)
|
|
82
|
-
artificialColumns.push('expander');
|
|
83
|
-
if (!ActionsRowComponent)
|
|
84
|
-
artificialColumns.push('actions');
|
|
85
|
-
setHiddenColumns(artificialColumns);
|
|
83
|
+
useUpdateEffect(() => {
|
|
84
|
+
const hiddenColumns = getHiddenColumns();
|
|
85
|
+
setHiddenColumns(hiddenColumns);
|
|
86
86
|
}, [
|
|
87
|
-
selectableRows,
|
|
88
87
|
setHiddenColumns,
|
|
89
|
-
|
|
90
|
-
hasSomeExpandableRows,
|
|
91
|
-
ActionsRowComponent
|
|
88
|
+
getHiddenColumns
|
|
92
89
|
]);
|
|
93
|
-
|
|
94
|
-
onSelectionChange?.(selectedFlatRows, selectedRowIds);
|
|
95
|
-
}, [onSelectionChange, selectedFlatRows, selectedRowIds]);
|
|
96
|
-
useEffect(() => {
|
|
90
|
+
useUpdateEffect(() => {
|
|
97
91
|
onSortChange?.(sortBy);
|
|
98
92
|
}, [onSortChange, sortBy]);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}, [
|
|
102
|
-
const rowEntries = useMemo(() =>
|
|
103
|
-
|
|
93
|
+
useUpdateEffect(() => {
|
|
94
|
+
onPaginationChange?.({ pageIndex, pageSize });
|
|
95
|
+
}, [onPaginationChange, pageIndex, pageSize]);
|
|
96
|
+
const rowEntries = useMemo(() => {
|
|
97
|
+
return (showPagination ? page : rows);
|
|
98
|
+
}, [page, rows, showPagination]);
|
|
99
|
+
const filteredVisibleColumns = useMemo(() => (visibleColumns.filter((col) => !col.isToggable)), [visibleColumns]);
|
|
104
100
|
const expandedRows = useMemo(() => rows.filter(row => row.canExpand && row.isExpanded).map(r => r.id), [rows]);
|
|
105
101
|
const dynamicStyle = {
|
|
106
102
|
'--table-height': height,
|
|
107
103
|
'--table-background': background
|
|
108
104
|
};
|
|
109
|
-
return (_jsxs("div", { className: clsx(styles.Table, className), style: { ...dynamicStyle, ...style }, children: [
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
105
|
+
return (_jsxs("div", { className: clsx(styles.Table, className), style: { ...dynamicStyle, ...style }, children: [_jsx(AnimatePresence, { children: _jsxs(LazyMotion, { features: domMax, children: [!!Object.keys(selectedRowIds).length && selectableRows && (_jsxs(Stack, { as: m.div, className: styles.Toast, direction: "row", hAlign: "space-between", vAlign: "center", hPadding: 16, vPadding: 8, fill: false, columnGap: 16, initial: { y: '-16px', opacity: 0 }, animate: {
|
|
106
|
+
y: 0,
|
|
107
|
+
opacity: 1,
|
|
108
|
+
transition: {
|
|
109
|
+
type: 'spring',
|
|
110
|
+
stiffness: 700,
|
|
111
|
+
damping: 30
|
|
112
|
+
}
|
|
113
|
+
}, exit: { y: '-16px', opacity: 0 }, children: [_jsx(Text, { as: "span", size: 14, weight: "bold", children: selectedLabel(Object.keys(selectedRowIds)) }), selectedActions?.(Object.keys(selectedRowIds))] })), (showHeader || selectableRows) && (_jsx(m.div, { animate: {
|
|
114
|
+
y: selectedFlatRows?.length ? 20 : 0,
|
|
115
|
+
opacity: selectedFlatRows?.length ? 0 : 1,
|
|
116
|
+
transition: {
|
|
117
|
+
type: 'spring',
|
|
118
|
+
stiffness: 700,
|
|
119
|
+
damping: 30
|
|
120
|
+
}
|
|
121
|
+
}, children: _jsxs(TableHeader, { title: title, children: [(columnsControl && data.length)
|
|
122
|
+
? (_jsx(ToggleColumnsControl, { columns: allColumns, visibleColumns: filteredVisibleColumns }))
|
|
123
|
+
: null, actions] }) }))] }) }), ((data.length || loading) && filteredVisibleColumns.length)
|
|
128
124
|
? (_jsx("div", { className: styles.TableWrapper, "data-table-scrolling": Boolean(height), children: _jsxs("table", { className: styles.TableElement, "data-table-stripes": stripes, "data-table-separators": showSeparators, "data-table-loading": loading, "aria-labelledby": uid('table-title'), ...getTableProps(), ...otherProps, children: [showTableHead && (_jsx("thead", { role: "rowgroup", className: styles.THead, children: headerGroups.map(headerGroup => (_jsx(TableRow, { ...headerGroup.getHeaderGroupProps(), children: headerGroup.headers.map((column) => (_jsx(TableCell, { as: "th", width: column.minWidth === 0 ? undefined : column.minWidth, collapsed: column.isCollapsed, isSorted: column.isSorted, isSortedDesc: column.isSorted && column.isSortedDesc, align: column.align, ...column.getHeaderProps(column.getSortByToggleProps()), children: column.render('Header') }))) }))) })), _jsx("tbody", { role: "rowgroup", className: styles.TBody, ...getTableBodyProps(), children: loading
|
|
129
125
|
? (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 100, children: _jsx(Skeleton, { gap: 16, height: 24, count: 10 }) }) }))
|
|
130
126
|
: rowEntries.map((row) => {
|
|
131
127
|
prepareRow(row);
|
|
132
128
|
return (_jsxs(Fragment, { children: [_jsx(TableRow, { ...row.getRowProps(), expanded: (row.isExpanded && !row.subRows.some(subrow => subrow.isExpanded && subrow.canExpand)), rowData: row, expandedRows: expandedRows, children: row.cells.map((cell) => (_jsx(TableCell, { collapsed: cell.column.isCollapsed, width: cell.column.minWidth === 0 ? undefined : cell.column.minWidth, align: cell.column.align, ...cell.getCellProps(), children: cell.render('Cell') }))) }), (row.subRows && row.isExpanded && expandableRowComponent) && row.subRows.map(subRow => (_jsx(TableRow, { "data-table-row-expander": true, children: _jsx(TableCell, { padding: false, colSpan: 100, children: _jsx(TableExpand, { data: subRow.original, component: expandableRowComponent }) }) }, subRow.id)))] }, row.id));
|
|
133
129
|
}) })] }) }))
|
|
134
|
-
: (_jsx(Stack, { vAlign: "center", hAlign: "center", children: emptyComponent ?? 'No data' })), (showPagination && filteredVisibleColumns.length > 0 && !!rows.length) && (_jsx(TablePagination, { clusters: pageClusters, pageSize: pageSize, totalItems: totalRows ?? rows.length, currentPage: pageIndex, totalPages: pageCount, isManual: Boolean(isManualPaginated && totalRows), onPageSizeChange:
|
|
130
|
+
: (_jsx(Stack, { vAlign: "center", hAlign: "center", children: emptyComponent ?? 'No data' })), (showPagination && filteredVisibleColumns.length > 0 && !!rows.length) && (_jsx(TablePagination, { clusters: pageClusters, pageSize: pageSize, totalItems: totalRows ?? rows.length, currentPage: pageIndex, totalPages: pageCount, isManual: Boolean(isManualPaginated && totalRows), onPageSizeChange: setPageSize, onPageClick: selected => gotoPage(selected) }))] }));
|
|
135
131
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { Column, ColumnInstance, CustomCell, CustomHeaderGroup } from 'react-table';
|
|
3
|
-
export declare type
|
|
3
|
+
export declare type PaginationPageType = {
|
|
4
4
|
pageIndex: number;
|
|
5
5
|
pageSize: number;
|
|
6
6
|
};
|
|
7
7
|
export declare type OptionalColumnTypes = {
|
|
8
8
|
isCollapsed?: boolean;
|
|
9
9
|
align?: 'start' | 'center' | 'end';
|
|
10
|
-
|
|
10
|
+
isToggable?: boolean;
|
|
11
11
|
expander?: boolean;
|
|
12
12
|
};
|
|
13
13
|
export declare type OptionalDataTypes<T> = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/table/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EACL,MAAM,EAAE,cAAc,EACtB,UAAU,EACV,iBAAiB,EAClB,MAAM,aAAa,CAAA;AAEpB,oBAAY,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/table/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EACL,MAAM,EAAE,cAAc,EACtB,UAAU,EACV,iBAAiB,EAClB,MAAM,aAAa,CAAA;AAEpB,oBAAY,kBAAkB,GAAG;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAA;AAED,oBAAY,mBAAmB,GAAG;IAChC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAA;AAED,oBAAY,iBAAiB,CAAC,CAAC,IAAI;IACjC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;IACd,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,CAAC;CACnC,CAAA;AAED,oBAAY,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,iBAAiB,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAA;AAC1G,oBAAY,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,UAAU,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAA;AAC5F,oBAAY,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAC,CAAA;AACzG,oBAAY,wBAAwB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,GAAG,mBAAmB,CAAA;AACjH,oBAAY,iBAAiB,CAAC,CAAC,IAAI;IACjC,EAAE,EAAE,MAAM,CAAC,CAAC;IACZ,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-button.d.ts","sourceRoot":"","sources":["../../../src/components/toggle-button/toggle-button.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAmB,MAAM,cAAc,CAAA;AAExF,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAGlC,oBAAY,iBAAiB,GAAG,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,GAAG;IAChE;;OAEG;IACH,WAAW,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IACrC;;OAEG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IACtC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAA;AAED,aAAK,uBAAuB,GAAG,WAAW,CAAC,mBAAmB,CAC5D,WAAW,CAAC,gBAAgB,CAAC,OAAO,UAAU,CAAC,EAC/C,WAAW,CAAC,QAAQ,CAAC,OAAO,UAAU,CAAC,GAAG,iBAAiB,CAC5D,CAAC;AAqBF,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"toggle-button.d.ts","sourceRoot":"","sources":["../../../src/components/toggle-button/toggle-button.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAmB,MAAM,cAAc,CAAA;AAExF,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAGlC,oBAAY,iBAAiB,GAAG,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,GAAG;IAChE;;OAEG;IACH,WAAW,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IACrC;;OAEG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IACtC;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAA;AAED,aAAK,uBAAuB,GAAG,WAAW,CAAC,mBAAmB,CAC5D,WAAW,CAAC,gBAAgB,CAAC,OAAO,UAAU,CAAC,EAC/C,WAAW,CAAC,QAAQ,CAAC,OAAO,UAAU,CAAC,GAAG,iBAAiB,CAC5D,CAAC;AAqBF,eAAO,MAAM,YAAY,yBA8EI,CAAA"}
|
|
@@ -3,7 +3,7 @@ import { forwardRef, useCallback, useEffect, useState } from 'react';
|
|
|
3
3
|
import styles from './toggle-button.module.css';
|
|
4
4
|
import { IconButton, Icon } from '../..';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
import {
|
|
6
|
+
import { domMax, LazyMotion, m } from 'framer-motion';
|
|
7
7
|
const scaleAnimation = {
|
|
8
8
|
scaleIn: {
|
|
9
9
|
scale: 1,
|
|
@@ -40,7 +40,7 @@ export const ToggleButton = forwardRef(({ className, restingIcon, pressedIcon, d
|
|
|
40
40
|
};
|
|
41
41
|
return (_jsx(Icon, { source: icon, dimension: iconSize[dimension] }));
|
|
42
42
|
}, []);
|
|
43
|
-
return (_jsx(IconButton, { as: "button", ref: forwardedRef, dimension: dimension, "aria-pressed": isPressed, kind: kind, disabled: disabled, onClick: handleClick, className: clsx(styles.ToggleButton, className), ...otherProps, children: isPressed && pressedIcon
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
return (_jsx(IconButton, { as: "button", ref: forwardedRef, dimension: dimension, "aria-pressed": isPressed, kind: kind, disabled: disabled, onClick: handleClick, className: clsx(styles.ToggleButton, className), ...otherProps, children: _jsx(LazyMotion, { features: domMax, strict: true, children: isPressed && pressedIcon
|
|
44
|
+
? (_jsx(m.span, { variants: scaleAnimation, initial: firstRender && isPressed ? false : 'scaleOut', animate: "scaleIn", children: renderIcon(pressedIcon, dimension) }, "pressedIcon"))
|
|
45
|
+
: restingIcon && (_jsx(m.span, { variants: scaleAnimation, initial: firstRender && !isPressed ? false : 'scaleOut', animate: "scaleIn", children: renderIcon(restingIcon, dimension) }, "restingIcon")) }) }));
|
|
46
46
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wonderflow/react-components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "UI components from Wonderflow's Wanda design system",
|
|
5
5
|
"author": "Wonderflow",
|
|
6
6
|
"license": "MIT",
|
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
"typescript-plugin-css-modules": "3.4.0"
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
|
+
"@radix-ui/react-tabs": "0.1.5",
|
|
89
90
|
"ahooks": "3.3.0",
|
|
90
91
|
"clsx": "1.1.1",
|
|
91
92
|
"framer-motion": "6.2.8",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
interface TabsProps {
|
|
3
|
-
state: [number, React.Dispatch<React.SetStateAction<number>>];
|
|
4
|
-
}
|
|
5
|
-
export declare const Tabs: FC<TabsProps>;
|
|
6
|
-
export declare const useTabState: (children: React.ReactNode) => {
|
|
7
|
-
isActive: boolean;
|
|
8
|
-
onClick: () => void;
|
|
9
|
-
};
|
|
10
|
-
export declare const usePanelState: (children: React.ReactNode) => boolean;
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=primitive-tab.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"primitive-tab.d.ts","sourceRoot":"","sources":["../../../src/components/tab/primitive-tab.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,EAAE,EACH,MAAM,OAAO,CAAA;AAed,UAAU,SAAS;IACjB,KAAK,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;CAC9D;AAED,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAU9B,CAAA;AAED,eAAO,MAAM,WAAW,aAAc,MAAM,SAAS;;;CA+BpD,CAAA;AAED,eAAO,MAAM,aAAa,aAAc,MAAM,SAAS,YAiBtD,CAAA"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useState, useMemo, useContext } from 'react';
|
|
3
|
-
import useConstant from './use-constant';
|
|
4
|
-
const TabsState = createContext([]);
|
|
5
|
-
const Elements = createContext({
|
|
6
|
-
tabs: [],
|
|
7
|
-
panels: []
|
|
8
|
-
});
|
|
9
|
-
export const Tabs = ({ state: outerState, children }) => {
|
|
10
|
-
const innerState = useState(0);
|
|
11
|
-
const elements = useConstant(() => ({ tabs: [], panels: [] }));
|
|
12
|
-
const state = outerState || innerState;
|
|
13
|
-
return (_jsx(Elements.Provider, { value: elements, children: _jsx(TabsState.Provider, { value: state, children: children }) }));
|
|
14
|
-
};
|
|
15
|
-
export const useTabState = (children) => {
|
|
16
|
-
const [activeIndex, setActive] = useContext(TabsState);
|
|
17
|
-
const elements = useContext(Elements);
|
|
18
|
-
const tabIndex = useConstant(() => {
|
|
19
|
-
const currentIndex = elements.tabs.length;
|
|
20
|
-
const childrenIndex = elements.tabs.indexOf(children);
|
|
21
|
-
const isChildrenUnique = !elements.tabs.includes(children);
|
|
22
|
-
if (isChildrenUnique) {
|
|
23
|
-
elements.tabs.push(children);
|
|
24
|
-
}
|
|
25
|
-
return isChildrenUnique ? currentIndex : childrenIndex;
|
|
26
|
-
});
|
|
27
|
-
const onClick = useConstant(() => () => {
|
|
28
|
-
if (setActive) {
|
|
29
|
-
setActive(tabIndex);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
const state = useMemo(() => ({
|
|
33
|
-
isActive: activeIndex === tabIndex,
|
|
34
|
-
onClick
|
|
35
|
-
}), [activeIndex, onClick, tabIndex]);
|
|
36
|
-
return state;
|
|
37
|
-
};
|
|
38
|
-
export const usePanelState = (children) => {
|
|
39
|
-
const [activeIndex] = useContext(TabsState);
|
|
40
|
-
const elements = useContext(Elements);
|
|
41
|
-
const panelIndex = useConstant(() => {
|
|
42
|
-
const currentIndex = elements.panels.length;
|
|
43
|
-
const childrenIndex = elements.panels.indexOf(children);
|
|
44
|
-
const isChildrenUnique = !elements.panels.includes(children);
|
|
45
|
-
if (isChildrenUnique) {
|
|
46
|
-
elements.panels.push(children);
|
|
47
|
-
}
|
|
48
|
-
return isChildrenUnique ? currentIndex : childrenIndex;
|
|
49
|
-
});
|
|
50
|
-
return panelIndex === activeIndex;
|
|
51
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ButtonHTMLAttributes } from 'react';
|
|
2
|
-
import { IconProps } from '../..';
|
|
3
|
-
/**
|
|
4
|
-
* Tab.Item
|
|
5
|
-
* Public api
|
|
6
|
-
*/
|
|
7
|
-
export declare type TabItemProps = ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
8
|
-
/**
|
|
9
|
-
* An optional icon to show beside the tab label.
|
|
10
|
-
*/
|
|
11
|
-
icon?: IconProps['source'];
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Tab.Item
|
|
15
|
-
* Component
|
|
16
|
-
*/
|
|
17
|
-
export declare const TabItem: import("react").ForwardRefExoticComponent<ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
18
|
-
/**
|
|
19
|
-
* An optional icon to show beside the tab label.
|
|
20
|
-
*/
|
|
21
|
-
icon?: import("packages/icons/dist").IconNames | import("react").ReactElement<HTMLOrSVGElement, string | import("react").JSXElementConstructor<any>> | undefined;
|
|
22
|
-
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
23
|
-
//# sourceMappingURL=tab-item.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tab-item.d.ts","sourceRoot":"","sources":["../../../src/components/tab/tab-item.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,oBAAoB,EAErB,MAAM,OAAO,CAAA;AAId,OAAO,EAAe,SAAS,EAAE,MAAM,cAAc,CAAA;AAKrD;;;GAGG;AACH,oBAAY,YAAY,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,GAAG;IACnE;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;CAC5B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,OAAO;IAVlB;;OAEG;;qDA8DH,CAAA"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback, useRef, forwardRef } from 'react';
|
|
3
|
-
import { useRovingTabIndex, useFocusEffect } from 'react-roving-tabindex';
|
|
4
|
-
import { domMax, LazyMotion, m } from 'framer-motion';
|
|
5
|
-
import clsx from 'clsx';
|
|
6
|
-
import { Stack, Icon } from '../..';
|
|
7
|
-
import { useTabState } from './primitive-tab';
|
|
8
|
-
import styles from './tab.module.css';
|
|
9
|
-
/**
|
|
10
|
-
* Tab.Item
|
|
11
|
-
* Component
|
|
12
|
-
*/
|
|
13
|
-
export const TabItem = forwardRef(({ children, className, icon, id, ...otherProps }, forwardedRef) => {
|
|
14
|
-
const { onClick, isActive } = useTabState(children);
|
|
15
|
-
const internalRef = useRef(forwardedRef);
|
|
16
|
-
const [, focused, handleKeyDown, handleClick] = useRovingTabIndex(internalRef, false);
|
|
17
|
-
useFocusEffect(focused, internalRef);
|
|
18
|
-
const fireClick = useCallback(() => {
|
|
19
|
-
onClick();
|
|
20
|
-
handleClick();
|
|
21
|
-
}, [handleClick, onClick]);
|
|
22
|
-
return (_jsx(LazyMotion, { features: domMax, strict: true, children: _jsxs(Stack, { as: "button", direction: "row", vAlign: "center", hAlign: "start", fill: false, columnGap: 8, role: "tab", ref: internalRef, className: clsx(styles.TabItem, className), "aria-selected": isActive, onClick: fireClick, onKeyDown: handleKeyDown, onFocus: fireClick, type: "button", tabIndex: isActive ? 0 : -1, id: id, ...otherProps, children: [icon && _jsx(Icon, { source: icon, dimension: 16 }), children, isActive && (_jsx(m.span, { transition: { type: 'spring', duration: 0.4, bounce: 0 }, className: styles.Highlight, layoutId: id }))] }) }));
|
|
23
|
-
});
|
|
24
|
-
TabItem.displayName = 'Tab.Item';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { HTMLAttributes } from 'react';
|
|
2
|
-
export declare type TabListProps = HTMLAttributes<HTMLDivElement>;
|
|
3
|
-
/**
|
|
4
|
-
* Tab.List
|
|
5
|
-
* Component
|
|
6
|
-
*/
|
|
7
|
-
export declare const TabList: import("react").ForwardRefExoticComponent<TabListProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
8
|
-
//# sourceMappingURL=tab-list.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tab-list.d.ts","sourceRoot":"","sources":["../../../src/components/tab/tab-list.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAc,cAAc,EAAE,MAAM,OAAO,CAAA;AAKlD,oBAAY,YAAY,GAAG,cAAc,CAAC,cAAc,CAAC,CAAA;AAEzD;;;GAGG;AACH,eAAO,MAAM,OAAO,yGAgBlB,CAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
|
-
import { RovingTabIndexProvider } from 'react-roving-tabindex';
|
|
4
|
-
import clsx from 'clsx';
|
|
5
|
-
import styles from './tab.module.css';
|
|
6
|
-
/**
|
|
7
|
-
* Tab.List
|
|
8
|
-
* Component
|
|
9
|
-
*/
|
|
10
|
-
export const TabList = forwardRef(({ children, className, ...otherProps }, forwardedRef) => (_jsx("div", { ref: forwardedRef, role: "tablist", tabIndex: -1, className: clsx(styles.TabList, className), ...otherProps, children: _jsx(RovingTabIndexProvider, { children: children }) })));
|
|
11
|
-
TabList.displayName = 'Tab.List';
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { PropsWithChildren, ReactNode } from 'react';
|
|
2
|
-
import { IconNames } from '@wonderflow/icons';
|
|
3
|
-
/**
|
|
4
|
-
* Tab.Panel
|
|
5
|
-
* Public api
|
|
6
|
-
*/
|
|
7
|
-
export declare type TabPanelProps = PropsWithChildren<PropsWithClass> & {
|
|
8
|
-
/**
|
|
9
|
-
* Set the tab panel name and accessible label
|
|
10
|
-
*/
|
|
11
|
-
label: ReactNode;
|
|
12
|
-
/**
|
|
13
|
-
* Add an additional icon to the tab panel label, enforcing
|
|
14
|
-
* the meaning of the name and context.
|
|
15
|
-
*/
|
|
16
|
-
icon?: IconNames;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Tab.Panel
|
|
20
|
-
* Component
|
|
21
|
-
*/
|
|
22
|
-
export declare const TabPanel: import("react").ForwardRefExoticComponent<PropsWithClass & {
|
|
23
|
-
children?: ReactNode;
|
|
24
|
-
} & {
|
|
25
|
-
/**
|
|
26
|
-
* Set the tab panel name and accessible label
|
|
27
|
-
*/
|
|
28
|
-
label: ReactNode;
|
|
29
|
-
/**
|
|
30
|
-
* Add an additional icon to the tab panel label, enforcing
|
|
31
|
-
* the meaning of the name and context.
|
|
32
|
-
*/
|
|
33
|
-
icon?: IconNames | undefined;
|
|
34
|
-
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
35
|
-
//# sourceMappingURL=tab-panel.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tab-panel.d.ts","sourceRoot":"","sources":["../../../src/components/tab/tab-panel.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EACjB,SAAS,EACV,MAAM,OAAO,CAAA;AAEd,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAK7C;;;GAGG;AACH,oBAAY,aAAa,GAAG,iBAAiB,CAAC,cAAc,CAAC,GAAG;IAC9D;;OAEG;IACH,KAAK,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ;;;IAfnB;;OAEG;WACI,SAAS;IAChB;;;OAGG;;kDA0BH,CAAA"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import { usePanelState } from './primitive-tab';
|
|
5
|
-
import styles from './tab.module.css';
|
|
6
|
-
/**
|
|
7
|
-
* Tab.Panel
|
|
8
|
-
* Component
|
|
9
|
-
*/
|
|
10
|
-
export const TabPanel = forwardRef(({ children, className, ...otherProps }, forwardedRef) => {
|
|
11
|
-
const isActive = usePanelState(children);
|
|
12
|
-
return isActive
|
|
13
|
-
? (_jsx("div", { ref: forwardedRef, tabIndex: 0, className: clsx(styles.TabPanel, className), ...otherProps, children: children }))
|
|
14
|
-
: null;
|
|
15
|
-
});
|
|
16
|
-
TabPanel.displayName = 'Tab.Panel';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-constant.d.ts","sourceRoot":"","sources":["../../../src/components/tab/use-constant.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,CAAC,EAAG,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAQtD"}
|