@decisiv/ui-components 2.0.1-alpha.161 → 2.0.1-alpha.162
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/components/Tabs/Tab/index.d.ts +13 -0
- package/lib/components/Tabs/Tab/index.d.ts.map +1 -0
- package/lib/components/Tabs/Tab/index.js +88 -0
- package/lib/components/Tabs/{schema.tab.d.ts → Tab/schema.d.ts} +1 -1
- package/lib/components/Tabs/Tab/schema.d.ts.map +1 -0
- package/lib/components/Tabs/Tab/styles.d.ts +7 -0
- package/lib/components/Tabs/Tab/styles.d.ts.map +1 -0
- package/lib/components/Tabs/Tab/styles.js +37 -0
- package/lib/components/Tabs/context.d.ts +2 -2
- package/lib/components/Tabs/context.d.ts.map +1 -1
- package/lib/components/Tabs/context.js +1 -1
- package/lib/components/Tabs/index.d.ts +17 -6
- package/lib/components/Tabs/index.d.ts.map +1 -1
- package/lib/components/Tabs/index.js +94 -163
- package/lib/components/Tabs/styles.d.ts +4 -0
- package/lib/components/Tabs/styles.d.ts.map +1 -0
- package/lib/components/Tabs/styles.js +35 -0
- package/lib/components/index.d.ts +1 -1
- package/lib/components/index.d.ts.map +1 -1
- package/lib/components/index.js +28 -0
- package/package.json +2 -2
- package/lib/components/Tabs/Tab.d.ts +0 -5
- package/lib/components/Tabs/Tab.d.ts.map +0 -1
- package/lib/components/Tabs/Tab.js +0 -109
- package/lib/components/Tabs/schema.tab.d.ts.map +0 -1
- package/lib/components/Tabs/types.d.ts +0 -27
- package/lib/components/Tabs/types.d.ts.map +0 -1
- package/lib/components/Tabs/types.js +0 -5
- /package/lib/components/Tabs/{schema.tab.js → Tab/schema.js} +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { Ref, HTMLAttributes } from 'react';
|
|
2
|
+
import { IconProps } from '@decisiv/iconix';
|
|
3
|
+
export declare type TabIcon = (props: IconProps) => JSX.Element;
|
|
4
|
+
export interface TabProps extends Omit<HTMLAttributes<HTMLButtonElement>, 'size'> {
|
|
5
|
+
id: string;
|
|
6
|
+
ref?: Ref<HTMLButtonElement>;
|
|
7
|
+
icon?: TabIcon;
|
|
8
|
+
title: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const Tab: React.ForwardRefExoticComponent<Pick<TabProps, "title" | "style" | "onDragEnd" | "id" | "children" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "lang" | "placeholder" | "slot" | "spellCheck" | "tabIndex" | "inputMode" | "is" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "icon" | "disabled"> & React.RefAttributes<HTMLButtonElement>>;
|
|
12
|
+
export default Tab;
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Tabs/Tab/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAEZ,GAAG,EAKH,cAAc,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAQ5C,oBAAY,OAAO,GAAG,CAAC,KAAK,EAAE,SAAS,KAAK,GAAG,CAAC,OAAO,CAAC;AAExD,MAAM,WAAW,QACf,SAAQ,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACvD,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,GAAG,glJAsDR,CAAC;AAiBF,eAAe,GAAG,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _assignRef = _interopRequireDefault(require("../../../utils/assignRef"));
|
|
13
|
+
|
|
14
|
+
var _context = require("../context");
|
|
15
|
+
|
|
16
|
+
var _styles = require("./styles");
|
|
17
|
+
|
|
18
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
23
|
+
|
|
24
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
25
|
+
|
|
26
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
27
|
+
|
|
28
|
+
var Tab = (0, _react.forwardRef)(function (_ref, ref) {
|
|
29
|
+
var id = _ref.id,
|
|
30
|
+
children = _ref.children,
|
|
31
|
+
icon = _ref.icon,
|
|
32
|
+
title = _ref.title,
|
|
33
|
+
onClick = _ref.onClick,
|
|
34
|
+
disabled = _ref.disabled,
|
|
35
|
+
rest = _objectWithoutProperties(_ref, ["id", "children", "icon", "title", "onClick", "disabled"]);
|
|
36
|
+
|
|
37
|
+
var tabs = (0, _context.useTabs)();
|
|
38
|
+
var Icon = icon;
|
|
39
|
+
var isActive = id === tabs.activeId;
|
|
40
|
+
var internalRef = (0, _react.useRef)(null);
|
|
41
|
+
var handleClick = (0, _react.useCallback)(function (e) {
|
|
42
|
+
!disabled && tabs.activate(id);
|
|
43
|
+
onClick && onClick(e);
|
|
44
|
+
}, [id, tabs, disabled, onClick]);
|
|
45
|
+
|
|
46
|
+
var assignRefs = function assignRefs(node) {
|
|
47
|
+
(0, _assignRef.default)(ref, node);
|
|
48
|
+
(0, _assignRef.default)(internalRef, node);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
(0, _react.useEffect)(function () {
|
|
52
|
+
var unregister = tabs.register(id, {
|
|
53
|
+
isDisabled: !!disabled,
|
|
54
|
+
content: children,
|
|
55
|
+
ref: internalRef
|
|
56
|
+
});
|
|
57
|
+
return unregister;
|
|
58
|
+
}, [id, disabled, children, internalRef, tabs]);
|
|
59
|
+
return _react.default.createElement(_styles.TabContainer, _extends({}, rest, {
|
|
60
|
+
"aria-controls": "tab-panel-".concat(id),
|
|
61
|
+
"aria-selected": isActive,
|
|
62
|
+
disabled: !!disabled,
|
|
63
|
+
id: "tab-".concat(id),
|
|
64
|
+
onClick: handleClick,
|
|
65
|
+
onKeyDown: tabs.onKeyDown,
|
|
66
|
+
ref: assignRefs,
|
|
67
|
+
role: "tab",
|
|
68
|
+
size: tabs.size || 'normal',
|
|
69
|
+
tabIndex: isActive ? 0 : -1,
|
|
70
|
+
type: "button"
|
|
71
|
+
}), Icon && _react.default.createElement(Icon, {
|
|
72
|
+
size: "medium"
|
|
73
|
+
}), _react.default.createElement("span", null, title));
|
|
74
|
+
}); // @ts-ignore
|
|
75
|
+
|
|
76
|
+
Tab.propTypes = {
|
|
77
|
+
id: _propTypes.default.string.isRequired,
|
|
78
|
+
title: _propTypes.default.string.isRequired,
|
|
79
|
+
icon: _propTypes.default.elementType,
|
|
80
|
+
disabled: _propTypes.default.bool
|
|
81
|
+
};
|
|
82
|
+
Tab.displayName = 'Tab';
|
|
83
|
+
Tab.defaultProps = {
|
|
84
|
+
icon: undefined,
|
|
85
|
+
disabled: false
|
|
86
|
+
};
|
|
87
|
+
var _default = Tab;
|
|
88
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../../src/components/Tabs/Tab/schema.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,MAAM,KAAmC,CAAC;AAqBhD,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TabProps } from '.';
|
|
2
|
+
interface StyledTabProps extends Omit<TabProps, 'title'> {
|
|
3
|
+
size: 'normal' | 'large';
|
|
4
|
+
}
|
|
5
|
+
export declare const TabContainer: import("styled-components").StyledComponent<"button", any, StyledTabProps, never>;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/components/Tabs/Tab/styles.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC;AAE7B,UAAU,cAAe,SAAQ,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC;IACtD,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC1B;AAMD,eAAO,MAAM,YAAY,mFAgFxB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TabContainer = void 0;
|
|
7
|
+
|
|
8
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
|
+
|
|
10
|
+
var _toColorString = _interopRequireDefault(require("polished/lib/color/toColorString"));
|
|
11
|
+
|
|
12
|
+
var _rem = _interopRequireDefault(require("polished/lib/helpers/rem"));
|
|
13
|
+
|
|
14
|
+
var _designTokens = require("@decisiv/design-tokens");
|
|
15
|
+
|
|
16
|
+
var _BaseButton = _interopRequireDefault(require("../../../atoms/BaseButton"));
|
|
17
|
+
|
|
18
|
+
var _styleModifiers = require("../../../utils/styleModifiers");
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
23
|
+
|
|
24
|
+
/* eslint-disable import/prefer-default-export */
|
|
25
|
+
var base = _designTokens.color.base,
|
|
26
|
+
interaction = _designTokens.color.interaction,
|
|
27
|
+
opacity = _designTokens.color.opacity;
|
|
28
|
+
var shadowColor = (0, _toColorString.default)(interaction.pacificOcean40);
|
|
29
|
+
var yPaddingBySize = {
|
|
30
|
+
normal: 5,
|
|
31
|
+
large: 10
|
|
32
|
+
};
|
|
33
|
+
var TabContainer = (0, _styledComponents.default)(_BaseButton.default).withConfig({
|
|
34
|
+
displayName: "styles__TabContainer",
|
|
35
|
+
componentId: "sc-3l38e9-0"
|
|
36
|
+
})(["color:", ";align-items:center;background:", ";border-radius:2px 2px 0 0;border:1px solid transparent;cursor:default;display:flex;font-size:", ";line-height:1.4;margin:0;outline:none;padding-top:", ";padding-right:", ";padding-bottom:", ";padding-left:", ";position:relative;font-weight:", ";&::after{background:", ";bottom:-1px;content:'';height:3px;left:2px;opacity:0;position:absolute;right:2px;}&:hover{color:", ";}&[aria-selected='true']{border-color:", ";border-bottom-color:transparent;color:", ";margin-bottom:-1px;padding-bottom:", ";&:focus{border-color:", ";border-bottom-color:", ";box-shadow:inset 0 0 0 2px ", ";&::after{opacity:1;}}}&:disabled{color:", ";cursor:not-allowed;}> *:not(span){margin-top:-1px;}> * + span{margin-left:", ";}", ";"], (0, _toColorString.default)(interaction.pacificOcean), (0, _toColorString.default)(base.snowWhite), (0, _rem.default)(_designTokens.typography.size.scale[1]), (0, _rem.default)(yPaddingBySize.normal + 3), (0, _rem.default)(15), (0, _rem.default)(yPaddingBySize.normal - 1), (0, _rem.default)(15), _designTokens.typography.weight.alias.medium, (0, _toColorString.default)(base.snowWhite), (0, _toColorString.default)(interaction.indianOcean), (0, _toColorString.default)(base.quarterMoon), (0, _toColorString.default)(base.alaskanHusky), (0, _rem.default)(yPaddingBySize.normal), (0, _toColorString.default)(interaction.pacificOcean), shadowColor, shadowColor, (0, _toColorString.default)(opacity.charcoal40), (0, _rem.default)(8), (0, _styleModifiers.when)('size', 'large', (0, _styledComponents.css)(["font-size:", ";line-height:1.2;padding-bottom:", ";padding-top:", ";&[aria-selected='true']{padding-bottom:", ";}"], (0, _rem.default)(_designTokens.typography.size.scale[2]), (0, _rem.default)(yPaddingBySize.large - 1), (0, _rem.default)(yPaddingBySize.large + 3), (0, _rem.default)(yPaddingBySize.large))));
|
|
37
|
+
exports.TabContainer = TabContainer;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { KeyboardEvent } from 'react';
|
|
2
|
-
import { TabData } from '
|
|
2
|
+
import { TabData } from '.';
|
|
3
3
|
declare const defaultCtxValue: {
|
|
4
4
|
activeId: string;
|
|
5
5
|
register(id: string, data: TabData): void;
|
|
6
6
|
onKeyDown(e: KeyboardEvent<HTMLButtonElement>): void;
|
|
7
|
-
|
|
7
|
+
activate(id: string): void;
|
|
8
8
|
};
|
|
9
9
|
export declare type CtxValue = typeof defaultCtxValue & {
|
|
10
10
|
size?: 'normal' | 'large';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,aAAa,EAAc,MAAM,OAAO,CAAC;AAE9E,OAAO,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,aAAa,EAAc,MAAM,OAAO,CAAC;AAE9E,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC;AAG5B,QAAA,MAAM,eAAe;;;;;CAKpB,CAAC;AAEF,oBAAY,QAAQ,GAAG,OAAO,eAAe,GAAG;IAC9C,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC3B,CAAC;AAGF,QAAA,MAAM,mBAAmB,kFAAuB,CAAC;AAEjD,QAAA,MAAM,OAAO,gBAAiE,CAAC;AAE/E,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -12,7 +12,7 @@ var defaultCtxValue = {
|
|
|
12
12
|
activeId: '',
|
|
13
13
|
register: function register(id, data) {},
|
|
14
14
|
onKeyDown: function onKeyDown(e) {},
|
|
15
|
-
|
|
15
|
+
activate: function activate(id) {}
|
|
16
16
|
};
|
|
17
17
|
var TabsContext = (0, _react.createContext)(defaultCtxValue);
|
|
18
18
|
var TabsContextProvider = TabsContext.Provider;
|
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import React, { Ref, HTMLAttributes, RefObject, ReactNode } from 'react';
|
|
2
|
+
export interface TabsProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
3
|
+
ref?: Ref<HTMLDivElement>;
|
|
4
|
+
size?: 'normal' | 'large';
|
|
5
|
+
onChange?: (id: string) => void;
|
|
6
|
+
selectedId?: string;
|
|
7
|
+
defaultSelectedId?: string;
|
|
8
|
+
renderHiddenTabsContent?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface TabData {
|
|
11
|
+
ref: RefObject<HTMLButtonElement>;
|
|
12
|
+
content: ReactNode;
|
|
13
|
+
isDisabled: boolean;
|
|
14
|
+
}
|
|
15
|
+
declare const Tabs: React.ForwardRefExoticComponent<Pick<TabsProps, "title" | "style" | "onDragEnd" | "size" | "id" | "children" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "lang" | "placeholder" | "slot" | "spellCheck" | "tabIndex" | "inputMode" | "is" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "selectedId" | "defaultSelectedId" | "renderHiddenTabsContent"> & React.RefAttributes<HTMLDivElement>>;
|
|
16
|
+
export { default as Tab, TabProps, TabIcon } from './Tab';
|
|
17
|
+
export default Tabs;
|
|
7
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/index.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAGZ,GAAG,EAIH,cAAc,EACd,SAAS,EACT,SAAS,EACV,MAAM,OAAO,CAAC;AAOf,MAAM,WAAW,SACf,SAAQ,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC;IACxD,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC1B,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAC;IAClC,OAAO,EAAE,SAAS,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,QAAA,MAAM,IAAI,koJAoIT,CAAC;AAqBF,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC1D,eAAe,IAAI,CAAC"}
|
|
@@ -3,45 +3,35 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
Tab: true
|
|
8
|
-
};
|
|
9
6
|
Object.defineProperty(exports, "Tab", {
|
|
10
7
|
enumerable: true,
|
|
11
8
|
get: function get() {
|
|
12
9
|
return _Tab.default;
|
|
13
10
|
}
|
|
14
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "TabProps", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _Tab.TabProps;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "TabIcon", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _Tab.TabIcon;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
15
24
|
exports.default = void 0;
|
|
16
25
|
|
|
17
26
|
var _react = _interopRequireWildcard(require("react"));
|
|
18
27
|
|
|
19
|
-
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
20
|
-
|
|
21
28
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
22
29
|
|
|
23
|
-
var _toColorString = _interopRequireDefault(require("polished/lib/color/toColorString"));
|
|
24
|
-
|
|
25
|
-
var _color = _interopRequireDefault(require("@decisiv/design-tokens/lib/color"));
|
|
26
|
-
|
|
27
|
-
var _usePrevious = _interopRequireDefault(require("../../utils/usePrevious"));
|
|
28
|
-
|
|
29
30
|
var _context = require("./context");
|
|
30
31
|
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
Object.keys(_types).forEach(function (key) {
|
|
34
|
-
if (key === "default" || key === "__esModule") return;
|
|
35
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
36
|
-
Object.defineProperty(exports, key, {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function get() {
|
|
39
|
-
return _types[key];
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
});
|
|
32
|
+
var _styles = require("./styles");
|
|
43
33
|
|
|
44
|
-
var _Tab =
|
|
34
|
+
var _Tab = _interopRequireWildcard(require("./Tab"));
|
|
45
35
|
|
|
46
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
47
37
|
|
|
@@ -49,14 +39,6 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
49
39
|
|
|
50
40
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
51
41
|
|
|
52
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
|
|
53
|
-
|
|
54
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
|
|
55
|
-
|
|
56
|
-
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
|
|
57
|
-
|
|
58
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
|
|
59
|
-
|
|
60
42
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
61
43
|
|
|
62
44
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
|
|
@@ -69,110 +51,77 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
69
51
|
|
|
70
52
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
71
53
|
|
|
72
|
-
var
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
var TabContent = _styledComponents.default.div.withConfig({
|
|
83
|
-
displayName: "Tabs__TabContent",
|
|
84
|
-
componentId: "tlr0dr-2"
|
|
85
|
-
})(["&:active,&:focus{outline:none;}"]);
|
|
86
|
-
|
|
87
|
-
var Tabs = function Tabs(props, ref) {
|
|
88
|
-
var _props$size = props.size,
|
|
89
|
-
size = _props$size === void 0 ? 'normal' : _props$size,
|
|
90
|
-
children = props.children,
|
|
91
|
-
onChange = props.onChange,
|
|
92
|
-
selectedId = props.selectedId,
|
|
93
|
-
defaultSelectedId = props.defaultSelectedId,
|
|
94
|
-
_props$renderHiddenTa = props.renderHiddenTabsContent,
|
|
95
|
-
renderHiddenTabsContent = _props$renderHiddenTa === void 0 ? true : _props$renderHiddenTa,
|
|
96
|
-
rest = _objectWithoutProperties(props, ["size", "children", "onChange", "selectedId", "defaultSelectedId", "renderHiddenTabsContent"]);
|
|
97
|
-
|
|
98
|
-
var prevChildren = (0, _usePrevious.default)(children);
|
|
99
|
-
var prevSelectedId = (0, _usePrevious.default)(selectedId);
|
|
100
|
-
var initialActiveId = selectedId || defaultSelectedId || '';
|
|
101
|
-
var autoSelectActiveId = (0, _react.useRef)(!initialActiveId);
|
|
54
|
+
var Tabs = (0, _react.forwardRef)(function (_ref, ref) {
|
|
55
|
+
var _ref$size = _ref.size,
|
|
56
|
+
size = _ref$size === void 0 ? 'normal' : _ref$size,
|
|
57
|
+
children = _ref.children,
|
|
58
|
+
onChange = _ref.onChange,
|
|
59
|
+
selectedId = _ref.selectedId,
|
|
60
|
+
defaultSelectedId = _ref.defaultSelectedId,
|
|
61
|
+
_ref$renderHiddenTabs = _ref.renderHiddenTabsContent,
|
|
62
|
+
renderHiddenTabsContent = _ref$renderHiddenTabs === void 0 ? true : _ref$renderHiddenTabs,
|
|
63
|
+
rest = _objectWithoutProperties(_ref, ["size", "children", "onChange", "selectedId", "defaultSelectedId", "renderHiddenTabsContent"]);
|
|
102
64
|
|
|
103
65
|
var _useState = (0, _react.useState)(new Map()),
|
|
104
|
-
_useState2 = _slicedToArray(_useState,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
66
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
67
|
+
registeredTabs = _useState2[0],
|
|
68
|
+
setRegisteredTabs = _useState2[1];
|
|
69
|
+
|
|
70
|
+
var enabledIds = (0, _react.useMemo)(function () {
|
|
71
|
+
return Array.from(registeredTabs).filter(function (_ref2) {
|
|
72
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
73
|
+
_id = _ref3[0],
|
|
74
|
+
data = _ref3[1];
|
|
75
|
+
|
|
76
|
+
return data.isDisabled === false;
|
|
77
|
+
}).map(function (_ref4) {
|
|
78
|
+
var _ref5 = _slicedToArray(_ref4, 1),
|
|
79
|
+
id = _ref5[0];
|
|
80
|
+
|
|
81
|
+
return id;
|
|
82
|
+
});
|
|
83
|
+
}, [registeredTabs]);
|
|
84
|
+
|
|
85
|
+
var _useMemo = (0, _react.useMemo)(function () {
|
|
86
|
+
return enabledIds;
|
|
87
|
+
}, [enabledIds]),
|
|
88
|
+
_useMemo2 = _slicedToArray(_useMemo, 1),
|
|
89
|
+
firstTabId = _useMemo2[0];
|
|
90
|
+
|
|
91
|
+
var _useState3 = (0, _react.useState)(defaultSelectedId),
|
|
108
92
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
var
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
setTabsOrder = _useState6[1];
|
|
116
|
-
|
|
117
|
-
var _useState7 = (0, _react.useState)([]),
|
|
118
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
119
|
-
enabledIds = _useState8[0],
|
|
120
|
-
setEnabledIds = _useState8[1]; // If "children" changes, we start all over
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
(0, _react.useEffect)(function () {
|
|
124
|
-
if (prevChildren && children !== prevChildren) {
|
|
125
|
-
autoSelectActiveId.current = !initialActiveId;
|
|
126
|
-
setActiveId(initialActiveId);
|
|
127
|
-
setTabsOrder([]);
|
|
128
|
-
setEnabledIds([]);
|
|
129
|
-
}
|
|
130
|
-
}, [initialActiveId, prevChildren, children]);
|
|
131
|
-
(0, _react.useEffect)(function () {
|
|
132
|
-
if (selectedId !== prevSelectedId) {
|
|
133
|
-
setActiveId(selectedId || '');
|
|
134
|
-
}
|
|
135
|
-
}, [tabs, prevSelectedId, selectedId]);
|
|
93
|
+
uncontrolledActiveId = _useState4[0],
|
|
94
|
+
setUncontrolledActiveId = _useState4[1];
|
|
95
|
+
|
|
96
|
+
var activeId = (0, _react.useMemo)(function () {
|
|
97
|
+
return selectedId || uncontrolledActiveId || firstTabId;
|
|
98
|
+
}, [selectedId, uncontrolledActiveId, firstTabId]);
|
|
136
99
|
var register = (0, _react.useCallback)(function (id, data) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
!data.isDisabled && setEnabledIds(function (ids) {
|
|
148
|
-
return [].concat(_toConsumableArray(ids), [id]);
|
|
100
|
+
setRegisteredTabs(function (oldState) {
|
|
101
|
+
var newMap = new Map(oldState);
|
|
102
|
+
newMap.set(id, data);
|
|
103
|
+
return newMap;
|
|
104
|
+
});
|
|
105
|
+
return function () {
|
|
106
|
+
setRegisteredTabs(function (oldState) {
|
|
107
|
+
var newMap = new Map(oldState);
|
|
108
|
+
newMap.delete(id);
|
|
109
|
+
return newMap;
|
|
149
110
|
});
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
var activateById = (0, _react.useCallback)(function (id) {
|
|
156
|
-
var tabData = tabs.get(id);
|
|
157
|
-
/* istanbul ignore else */
|
|
111
|
+
};
|
|
112
|
+
}, []);
|
|
113
|
+
var activate = (0, _react.useCallback)(function (id) {
|
|
114
|
+
onChange && onChange(id);
|
|
115
|
+
var tabData = registeredTabs.get(id);
|
|
158
116
|
|
|
159
117
|
if (tabData && tabData.ref.current) {
|
|
160
118
|
tabData.ref.current.focus();
|
|
161
119
|
}
|
|
162
|
-
/* istanbul ignore else */
|
|
163
120
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
// Only activate if we are not a controlled component
|
|
167
|
-
if (selectedId !== undefined) {
|
|
168
|
-
onChange && onChange(id);
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
setActiveId(id);
|
|
173
|
-
onChange && onChange(id);
|
|
121
|
+
if (!selectedId) {
|
|
122
|
+
setUncontrolledActiveId(id);
|
|
174
123
|
}
|
|
175
|
-
}, [
|
|
124
|
+
}, [selectedId, registeredTabs, onChange]);
|
|
176
125
|
var onKeyDown = (0, _react.useCallback)(function (event) {
|
|
177
126
|
var totalIds = enabledIds.length;
|
|
178
127
|
var activeIdx = enabledIds.indexOf(activeId);
|
|
@@ -195,49 +144,31 @@ var Tabs = function Tabs(props, ref) {
|
|
|
195
144
|
newActiveIdx = totalIds - 1;
|
|
196
145
|
break;
|
|
197
146
|
}
|
|
198
|
-
/* istanbul ignore else */
|
|
199
|
-
|
|
200
147
|
|
|
201
148
|
if (newActiveIdx !== activeIdx) {
|
|
202
|
-
|
|
203
|
-
var tabData = tabs.get(newActiveId);
|
|
204
|
-
|
|
205
|
-
if (selectedId !== undefined) {
|
|
206
|
-
onChange && onChange(newActiveId);
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
/* istanbul ignore else */
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (tabData && tabData.ref.current) {
|
|
213
|
-
tabData.ref.current.focus();
|
|
214
|
-
}
|
|
215
|
-
/* istanbul ignore else */
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (newActiveId !== activeId) {
|
|
219
|
-
setActiveId(newActiveId);
|
|
220
|
-
onChange && onChange(newActiveId);
|
|
221
|
-
}
|
|
149
|
+
activate(enabledIds[newActiveIdx]);
|
|
222
150
|
}
|
|
223
|
-
}, [
|
|
224
|
-
var
|
|
151
|
+
}, [activeId, enabledIds, activate]);
|
|
152
|
+
var values = (0, _react.useMemo)(function () {
|
|
225
153
|
return {
|
|
226
|
-
size: size,
|
|
227
|
-
activeId: activeId,
|
|
228
154
|
register: register,
|
|
229
|
-
|
|
155
|
+
activeId: activeId,
|
|
156
|
+
activate: activate,
|
|
157
|
+
size: size,
|
|
230
158
|
onKeyDown: onKeyDown
|
|
231
159
|
};
|
|
232
|
-
}, [
|
|
160
|
+
}, [register, activeId, activate, size, onKeyDown]);
|
|
233
161
|
return _react.default.createElement(_context.TabsContextProvider, {
|
|
234
|
-
value:
|
|
235
|
-
}, _react.default.createElement(Container, _extends({}, rest, {
|
|
162
|
+
value: values
|
|
163
|
+
}, _react.default.createElement(_styles.Container, _extends({}, rest, {
|
|
236
164
|
ref: ref
|
|
237
|
-
}), _react.default.createElement(TabList, null, children),
|
|
238
|
-
var
|
|
165
|
+
}), _react.default.createElement(_styles.TabList, null, children), Array.from(registeredTabs, function (_ref6, index) {
|
|
166
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
|
167
|
+
id = _ref7[0],
|
|
168
|
+
data = _ref7[1];
|
|
169
|
+
|
|
239
170
|
var isActive = id === activeId || !activeId && index === 0;
|
|
240
|
-
return _react.default.createElement(TabContent, {
|
|
171
|
+
return _react.default.createElement(_styles.TabContent, {
|
|
241
172
|
key: id,
|
|
242
173
|
id: "tab-panel-".concat(id),
|
|
243
174
|
"aria-hidden": !isActive || !data,
|
|
@@ -247,22 +178,22 @@ var Tabs = function Tabs(props, ref) {
|
|
|
247
178
|
tabIndex: isActive ? 0 : -1
|
|
248
179
|
}, (isActive || renderHiddenTabsContent) && data && data.content);
|
|
249
180
|
})));
|
|
250
|
-
};
|
|
181
|
+
});
|
|
182
|
+
Tabs.displayName = 'Tabs'; // @ts-ignore
|
|
251
183
|
|
|
252
|
-
|
|
253
|
-
TabsWithRef.propTypes = {
|
|
184
|
+
Tabs.propTypes = {
|
|
254
185
|
size: _propTypes.default.oneOf(['normal', 'large']),
|
|
255
186
|
selectedId: _propTypes.default.string,
|
|
256
187
|
defaultSelectedId: _propTypes.default.string,
|
|
257
188
|
renderHiddenTabsContent: _propTypes.default.bool,
|
|
258
189
|
onChange: _propTypes.default.func
|
|
259
190
|
};
|
|
260
|
-
|
|
191
|
+
Tabs.defaultProps = {
|
|
261
192
|
size: 'normal',
|
|
262
193
|
selectedId: undefined,
|
|
263
194
|
defaultSelectedId: undefined,
|
|
264
195
|
renderHiddenTabsContent: true,
|
|
265
196
|
onChange: undefined
|
|
266
197
|
};
|
|
267
|
-
var _default =
|
|
198
|
+
var _default = Tabs;
|
|
268
199
|
exports.default = _default;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const Container: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const TabList: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const TabContent: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS,oEAGrB,CAAC;AAEF,eAAO,MAAM,OAAO,oEAInB,CAAC;AAEF,eAAO,MAAM,UAAU,oEAKtB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TabContent = exports.TabList = exports.Container = void 0;
|
|
7
|
+
|
|
8
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
+
|
|
10
|
+
var _toColorString = _interopRequireDefault(require("polished/lib/color/toColorString"));
|
|
11
|
+
|
|
12
|
+
var _color = _interopRequireDefault(require("@decisiv/design-tokens/lib/color"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
var Container = _styledComponents.default.div.withConfig({
|
|
17
|
+
displayName: "styles__Container",
|
|
18
|
+
componentId: "sc-1o82gsh-0"
|
|
19
|
+
})(["display:flex;flex-direction:column;"]);
|
|
20
|
+
|
|
21
|
+
exports.Container = Container;
|
|
22
|
+
|
|
23
|
+
var TabList = _styledComponents.default.div.withConfig({
|
|
24
|
+
displayName: "styles__TabList",
|
|
25
|
+
componentId: "sc-1o82gsh-1"
|
|
26
|
+
})(["align-items:flex-end;border-bottom:1px solid ", ";display:flex;"], (0, _toColorString.default)(_color.default.base.quarterMoon));
|
|
27
|
+
|
|
28
|
+
exports.TabList = TabList;
|
|
29
|
+
|
|
30
|
+
var TabContent = _styledComponents.default.div.withConfig({
|
|
31
|
+
displayName: "styles__TabContent",
|
|
32
|
+
componentId: "sc-1o82gsh-2"
|
|
33
|
+
})(["&:active,&:focus{outline:none;}"]);
|
|
34
|
+
|
|
35
|
+
exports.TabContent = TabContent;
|
|
@@ -31,7 +31,7 @@ export { default as SelectDate, DisabledDateRuleName, DayOfWeek, } from './Selec
|
|
|
31
31
|
export { default as SelectDateRange } from './SelectDateRange';
|
|
32
32
|
export { default as SelectMenu } from './SelectMenu';
|
|
33
33
|
export { default as Table, TableProps } from './Table';
|
|
34
|
-
export { default as Tabs, Tab } from './Tabs';
|
|
34
|
+
export { default as Tabs, Tab, TabsProps, TabData, TabIcon, TabProps, } from './Tabs';
|
|
35
35
|
export { default as Tag, TagActionButtonRef, TagRef } from './Tag';
|
|
36
36
|
export { default as TextArea } from './TextArea';
|
|
37
37
|
export { default as TextField } from './TextField';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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AAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,cAAc,cAAc,CAAC"}
|
package/lib/components/index.js
CHANGED
|
@@ -64,6 +64,10 @@ var _exportNames = {
|
|
|
64
64
|
TableProps: true,
|
|
65
65
|
Tabs: true,
|
|
66
66
|
Tab: true,
|
|
67
|
+
TabsProps: true,
|
|
68
|
+
TabData: true,
|
|
69
|
+
TabIcon: true,
|
|
70
|
+
TabProps: true,
|
|
67
71
|
Tag: true,
|
|
68
72
|
TagActionButtonRef: true,
|
|
69
73
|
TagRef: true,
|
|
@@ -434,6 +438,30 @@ Object.defineProperty(exports, "Tab", {
|
|
|
434
438
|
return _Tabs.Tab;
|
|
435
439
|
}
|
|
436
440
|
});
|
|
441
|
+
Object.defineProperty(exports, "TabsProps", {
|
|
442
|
+
enumerable: true,
|
|
443
|
+
get: function get() {
|
|
444
|
+
return _Tabs.TabsProps;
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
Object.defineProperty(exports, "TabData", {
|
|
448
|
+
enumerable: true,
|
|
449
|
+
get: function get() {
|
|
450
|
+
return _Tabs.TabData;
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
Object.defineProperty(exports, "TabIcon", {
|
|
454
|
+
enumerable: true,
|
|
455
|
+
get: function get() {
|
|
456
|
+
return _Tabs.TabIcon;
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
Object.defineProperty(exports, "TabProps", {
|
|
460
|
+
enumerable: true,
|
|
461
|
+
get: function get() {
|
|
462
|
+
return _Tabs.TabProps;
|
|
463
|
+
}
|
|
464
|
+
});
|
|
437
465
|
Object.defineProperty(exports, "Tag", {
|
|
438
466
|
enumerable: true,
|
|
439
467
|
get: function get() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decisiv/ui-components",
|
|
3
|
-
"version": "2.0.1-alpha.
|
|
3
|
+
"version": "2.0.1-alpha.162+1633819",
|
|
4
4
|
"description": "Decisiv's design system React components",
|
|
5
5
|
"author": "Decisiv UI Development Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
73
|
"private": false,
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "1633819ff8ff705affe08c74759c902d34ff00b6"
|
|
75
75
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Tab.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/Tab.tsx"],"names":[],"mappings":"AAGA,OAAc,EAGZ,sBAAsB,EAIvB,MAAM,OAAO,CAAC;AAWf,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AA4I3C,QAAA,MAAM,UAAU,EAAE,sBAAsB,CAAC,MAAM,EAAE,QAAQ,CAAmB,CAAC;AAe7E,eAAe,UAAU,CAAC"}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _toColorString = _interopRequireDefault(require("polished/lib/color/toColorString"));
|
|
9
|
-
|
|
10
|
-
var _rem = _interopRequireDefault(require("polished/lib/helpers/rem"));
|
|
11
|
-
|
|
12
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
-
|
|
16
|
-
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
17
|
-
|
|
18
|
-
var _designTokens = require("@decisiv/design-tokens");
|
|
19
|
-
|
|
20
|
-
var _BaseButton = _interopRequireDefault(require("../../atoms/BaseButton"));
|
|
21
|
-
|
|
22
|
-
var _assignRef = _interopRequireDefault(require("../../utils/assignRef"));
|
|
23
|
-
|
|
24
|
-
var _styleModifiers = require("../../utils/styleModifiers");
|
|
25
|
-
|
|
26
|
-
var _context = require("./context");
|
|
27
|
-
|
|
28
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
29
|
-
|
|
30
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
|
|
32
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
33
|
-
|
|
34
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
35
|
-
|
|
36
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
37
|
-
|
|
38
|
-
var base = _designTokens.color.base,
|
|
39
|
-
interaction = _designTokens.color.interaction,
|
|
40
|
-
opacity = _designTokens.color.opacity;
|
|
41
|
-
var shadowColor = (0, _toColorString.default)(interaction.pacificOcean40);
|
|
42
|
-
var yPaddingBySize = {
|
|
43
|
-
normal: 5,
|
|
44
|
-
large: 10
|
|
45
|
-
};
|
|
46
|
-
var StyledTab = (0, _styledComponents.default)(_BaseButton.default).withConfig({
|
|
47
|
-
displayName: "Tab__StyledTab",
|
|
48
|
-
componentId: "txb60x-0"
|
|
49
|
-
})(["color:", ";align-items:center;background:", ";border-radius:2px 2px 0 0;border:1px solid transparent;cursor:default;display:flex;font-size:", ";line-height:1.4;margin:0;outline:none;padding-top:", ";padding-right:", ";padding-bottom:", ";padding-left:", ";position:relative;font-weight:", ";&::after{background:", ";bottom:-1px;content:'';height:3px;left:2px;opacity:0;position:absolute;right:2px;}&:hover{color:", ";}&[aria-selected='true']{border-color:", ";border-bottom-color:transparent;color:", ";margin-bottom:-1px;padding-bottom:", ";&:focus{border-color:", ";border-bottom-color:", ";box-shadow:inset 0 0 0 2px ", ";&::after{opacity:1;}}}&:disabled{color:", ";cursor:not-allowed;}> *:not(span){margin-top:-1px;}> * + span{margin-left:", ";}", ";"], (0, _toColorString.default)(interaction.pacificOcean), (0, _toColorString.default)(base.snowWhite), (0, _rem.default)(_designTokens.typography.size.scale[1]), (0, _rem.default)(yPaddingBySize.normal + 3), (0, _rem.default)(15), (0, _rem.default)(yPaddingBySize.normal - 1), (0, _rem.default)(15), _designTokens.typography.weight.alias.medium, (0, _toColorString.default)(base.snowWhite), (0, _toColorString.default)(interaction.indianOcean), (0, _toColorString.default)(base.quarterMoon), (0, _toColorString.default)(base.alaskanHusky), (0, _rem.default)(yPaddingBySize.normal), (0, _toColorString.default)(interaction.pacificOcean), shadowColor, shadowColor, (0, _toColorString.default)(opacity.charcoal40), (0, _rem.default)(8), (0, _styleModifiers.when)('size', 'large', (0, _styledComponents.css)(["font-size:", ";line-height:1.2;padding-bottom:", ";padding-top:", ";&[aria-selected='true']{padding-bottom:", ";}"], (0, _rem.default)(_designTokens.typography.size.scale[2]), (0, _rem.default)(yPaddingBySize.large - 1), (0, _rem.default)(yPaddingBySize.large + 3), (0, _rem.default)(yPaddingBySize.large))));
|
|
50
|
-
|
|
51
|
-
var Tab = function Tab(props, ref) {
|
|
52
|
-
var id = props.id,
|
|
53
|
-
children = props.children,
|
|
54
|
-
icon = props.icon,
|
|
55
|
-
title = props.title,
|
|
56
|
-
onClick = props.onClick,
|
|
57
|
-
disabled = props.disabled,
|
|
58
|
-
rest = _objectWithoutProperties(props, ["id", "children", "icon", "title", "onClick", "disabled"]);
|
|
59
|
-
|
|
60
|
-
var tabs = (0, _context.useTabs)();
|
|
61
|
-
var Icon = icon;
|
|
62
|
-
var isActive = id === tabs.activeId;
|
|
63
|
-
var internalRef = (0, _react.useRef)(null);
|
|
64
|
-
var handleClick = (0, _react.useCallback)(function (e) {
|
|
65
|
-
!disabled && tabs.activateById(id);
|
|
66
|
-
onClick && onClick(e);
|
|
67
|
-
}, [id, tabs, disabled, onClick]);
|
|
68
|
-
|
|
69
|
-
var assignRefs = function assignRefs(node) {
|
|
70
|
-
(0, _assignRef.default)(ref, node);
|
|
71
|
-
(0, _assignRef.default)(internalRef, node);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
tabs.register(id, {
|
|
75
|
-
isDisabled: !!disabled,
|
|
76
|
-
content: children,
|
|
77
|
-
ref: internalRef
|
|
78
|
-
});
|
|
79
|
-
return _react.default.createElement(StyledTab, _extends({}, rest, {
|
|
80
|
-
"aria-controls": "tab-panel-".concat(id),
|
|
81
|
-
"aria-selected": isActive,
|
|
82
|
-
disabled: !!disabled,
|
|
83
|
-
id: "tab-".concat(id),
|
|
84
|
-
onClick: handleClick,
|
|
85
|
-
onKeyDown: tabs.onKeyDown,
|
|
86
|
-
ref: assignRefs,
|
|
87
|
-
role: "tab",
|
|
88
|
-
size: tabs.size || 'normal',
|
|
89
|
-
tabIndex: isActive ? 0 : -1,
|
|
90
|
-
type: "button"
|
|
91
|
-
}), Icon && _react.default.createElement(Icon, {
|
|
92
|
-
size: "medium"
|
|
93
|
-
}), _react.default.createElement("span", null, title));
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
var TabWithRef = (0, _react.forwardRef)(Tab); // @ts-ignore
|
|
97
|
-
|
|
98
|
-
TabWithRef.propTypes = {
|
|
99
|
-
id: _propTypes.default.string.isRequired,
|
|
100
|
-
title: _propTypes.default.string.isRequired,
|
|
101
|
-
icon: _propTypes.default.elementType,
|
|
102
|
-
disabled: _propTypes.default.bool
|
|
103
|
-
};
|
|
104
|
-
TabWithRef.defaultProps = {
|
|
105
|
-
icon: undefined,
|
|
106
|
-
disabled: false
|
|
107
|
-
};
|
|
108
|
-
var _default = TabWithRef;
|
|
109
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.tab.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/schema.tab.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,MAAM,KAAmC,CAAC;AAqBhD,eAAe,MAAM,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef, ReactNode, Ref, RefObject } from 'react';
|
|
2
|
-
import { IconProps } from '@decisiv/iconix';
|
|
3
|
-
declare type IconComponent = (props: IconProps) => JSX.Element;
|
|
4
|
-
export declare type TabsRef = HTMLDivElement;
|
|
5
|
-
export declare type TabRef = HTMLButtonElement;
|
|
6
|
-
export interface Props extends Omit<ComponentPropsWithoutRef<'div'>, 'onChange'> {
|
|
7
|
-
ref?: Ref<TabsRef>;
|
|
8
|
-
size?: 'normal' | 'large';
|
|
9
|
-
onChange?: (id: string) => void;
|
|
10
|
-
selectedId?: string;
|
|
11
|
-
defaultSelectedId?: string;
|
|
12
|
-
renderHiddenTabsContent?: boolean;
|
|
13
|
-
}
|
|
14
|
-
export interface TabData {
|
|
15
|
-
ref: RefObject<HTMLButtonElement>;
|
|
16
|
-
content: ReactNode;
|
|
17
|
-
isDisabled: boolean;
|
|
18
|
-
}
|
|
19
|
-
export interface TabProps extends Omit<ComponentPropsWithoutRef<'button'>, 'size'> {
|
|
20
|
-
id: string;
|
|
21
|
-
ref?: Ref<TabRef>;
|
|
22
|
-
icon?: IconComponent;
|
|
23
|
-
title: string;
|
|
24
|
-
disabled?: boolean;
|
|
25
|
-
}
|
|
26
|
-
export {};
|
|
27
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Tabs/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,aAAK,aAAa,GAAG,CAAC,KAAK,EAAE,SAAS,KAAK,GAAG,CAAC,OAAO,CAAC;AAEvD,oBAAY,OAAO,GAAG,cAAc,CAAC;AACrC,oBAAY,MAAM,GAAG,iBAAiB,CAAC;AAEvC,MAAM,WAAW,KACf,SAAQ,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IACzD,GAAG,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACnB,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC1B,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAC;IAClC,OAAO,EAAE,SAAS,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,QACf,SAAQ,IAAI,CAAC,wBAAwB,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IACxD,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClB,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
|
|
File without changes
|