@mongodb-js/compass-components 0.10.0 → 0.12.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/lib/compass-font-sizes.d.ts +2 -0
- package/lib/compass-font-sizes.d.ts.map +1 -0
- package/lib/compass-font-sizes.js +5 -0
- package/lib/compass-font-sizes.js.map +1 -0
- package/lib/compass-ui-colors.d.ts.map +1 -1
- package/lib/compass-ui-colors.js.map +1 -1
- package/lib/components/accordion.d.ts +1 -1
- package/lib/components/accordion.d.ts.map +1 -1
- package/lib/components/accordion.js +13 -12
- package/lib/components/accordion.js.map +1 -1
- package/lib/components/checkbox.d.ts +5 -0
- package/lib/components/checkbox.d.ts.map +1 -0
- package/lib/components/checkbox.js +19 -0
- package/lib/components/checkbox.js.map +1 -0
- package/lib/components/confirmation-modal.d.ts +1 -1
- package/lib/components/confirmation-modal.d.ts.map +1 -1
- package/lib/components/confirmation-modal.js +27 -6
- package/lib/components/confirmation-modal.js.map +1 -1
- package/lib/components/error-boundary.d.ts +1 -0
- package/lib/components/error-boundary.d.ts.map +1 -1
- package/lib/components/error-boundary.js +6 -1
- package/lib/components/error-boundary.js.map +1 -1
- package/lib/components/file-input.d.ts +1 -2
- package/lib/components/file-input.d.ts.map +1 -1
- package/lib/components/file-input.js +11 -27
- package/lib/components/file-input.js.map +1 -1
- package/lib/components/inline-info-link.d.ts +8 -0
- package/lib/components/inline-info-link.d.ts.map +1 -0
- package/lib/components/inline-info-link.js +23 -0
- package/lib/components/inline-info-link.js.map +1 -0
- package/lib/components/modal.d.ts +7 -0
- package/lib/components/modal.d.ts.map +1 -0
- package/lib/components/modal.js +39 -0
- package/lib/components/modal.js.map +1 -0
- package/lib/components/placeholder.d.ts.map +1 -1
- package/lib/components/placeholder.js +9 -8
- package/lib/components/placeholder.js.map +1 -1
- package/lib/components/radio-box-group.d.ts +5 -0
- package/lib/components/radio-box-group.d.ts.map +1 -0
- package/lib/components/radio-box-group.js +18 -0
- package/lib/components/radio-box-group.js.map +1 -0
- package/lib/components/spin-loader.d.ts +3 -9
- package/lib/components/spin-loader.d.ts.map +1 -1
- package/lib/components/spin-loader.js +10 -31
- package/lib/components/spin-loader.js.map +1 -1
- package/lib/components/toggle.d.ts +5 -0
- package/lib/components/toggle.d.ts.map +1 -0
- package/lib/components/toggle.js +15 -0
- package/lib/components/toggle.js.map +1 -0
- package/lib/components/virtual-grid.d.ts +4 -1
- package/lib/components/virtual-grid.d.ts.map +1 -1
- package/lib/components/virtual-grid.js +12 -4
- package/lib/components/virtual-grid.js.map +1 -1
- package/lib/hooks/use-sort.d.ts +22 -0
- package/lib/hooks/use-sort.d.ts.map +1 -0
- package/lib/hooks/use-sort.js +109 -0
- package/lib/hooks/use-sort.js.map +1 -0
- package/lib/hooks/use-theme.d.ts +15 -0
- package/lib/hooks/use-theme.d.ts.map +1 -0
- package/lib/hooks/use-theme.js +40 -0
- package/lib/hooks/use-theme.js.map +1 -0
- package/lib/hooks/use-toast.d.ts +17 -0
- package/lib/hooks/use-toast.d.ts.map +1 -0
- package/lib/hooks/use-toast.js +94 -0
- package/lib/hooks/use-toast.js.map +1 -0
- package/lib/index.d.ts +15 -8
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +35 -16
- package/lib/index.js.map +1 -1
- package/package.json +26 -25
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
interface SpinLoaderProps {
|
|
3
|
-
className: string;
|
|
4
3
|
size?: string;
|
|
5
4
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
size: string;
|
|
9
|
-
};
|
|
10
|
-
render(): JSX.Element;
|
|
11
|
-
}
|
|
12
|
-
export {};
|
|
5
|
+
declare function SpinLoader({ size }: SpinLoaderProps): JSX.Element;
|
|
6
|
+
export { SpinLoader };
|
|
13
7
|
//# sourceMappingURL=spin-loader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spin-loader.d.ts","sourceRoot":"","sources":["../../src/components/spin-loader.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spin-loader.d.ts","sourceRoot":"","sources":["../../src/components/spin-loader.tsx"],"names":[],"mappings":";AAIA,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAmBD,iBAAS,UAAU,CAAC,EAAE,IAAa,EAAE,EAAE,eAAe,GAAG,GAAG,CAAC,OAAO,CAUnE;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -1,25 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
4
|
};
|
|
21
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
|
|
6
|
+
exports.SpinLoader = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
23
8
|
const emotion_1 = require("@leafygreen-ui/emotion");
|
|
24
9
|
const palette_1 = require("@leafygreen-ui/palette");
|
|
25
10
|
const shellLoaderSpin = (0, emotion_1.keyframes) `
|
|
@@ -37,17 +22,11 @@ const spinLoaderStyle = (0, emotion_1.css) `
|
|
|
37
22
|
|
|
38
23
|
animation: ${shellLoaderSpin} 700ms ease infinite;
|
|
39
24
|
`;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
height: size,
|
|
46
|
-
} }));
|
|
47
|
-
}
|
|
25
|
+
function SpinLoader({ size = '12px' }) {
|
|
26
|
+
return (react_1.default.createElement("div", { className: spinLoaderStyle, style: {
|
|
27
|
+
width: size,
|
|
28
|
+
height: size,
|
|
29
|
+
} }));
|
|
48
30
|
}
|
|
49
|
-
exports.
|
|
50
|
-
SpinLoader.defaultProps = {
|
|
51
|
-
size: '12px',
|
|
52
|
-
};
|
|
31
|
+
exports.SpinLoader = SpinLoader;
|
|
53
32
|
//# sourceMappingURL=spin-loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spin-loader.js","sourceRoot":"","sources":["../../src/components/spin-loader.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"spin-loader.js","sourceRoot":"","sources":["../../src/components/spin-loader.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,oDAAwD;AACxD,oDAAkD;AAMlD,MAAM,eAAe,GAAG,IAAA,mBAAS,EAAA;;;CAGhC,CAAC;AAEF,MAAM,eAAe,GAAG,IAAA,aAAG,EAAA;;0BAED,kBAAQ,CAAC,IAAI,CAAC,KAAK;;;;;;;eAO9B,eAAe;CAC7B,CAAC;AAEF,SAAS,UAAU,CAAC,EAAE,IAAI,GAAG,MAAM,EAAmB;IACpD,OAAO,CACL,uCACE,SAAS,EAAE,eAAe,EAC1B,KAAK,EAAE;YACL,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,IAAI;SACb,GACD,CACH,CAAC;AACJ,CAAC;AAEQ,gCAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggle.d.ts","sourceRoot":"","sources":["../../src/components/toggle.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AAIrD,iBAAS,MAAM,CACb,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,GACnD,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAIrC;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Toggle = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const toggle_1 = __importDefault(require("@leafygreen-ui/toggle"));
|
|
9
|
+
const use_theme_1 = require("../hooks/use-theme");
|
|
10
|
+
function Toggle(props) {
|
|
11
|
+
const theme = (0, use_theme_1.useTheme)();
|
|
12
|
+
return react_1.default.createElement(toggle_1.default, { darkMode: (theme === null || theme === void 0 ? void 0 : theme.theme) === use_theme_1.Theme.Dark, ...props });
|
|
13
|
+
}
|
|
14
|
+
exports.Toggle = Toggle;
|
|
15
|
+
//# sourceMappingURL=toggle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggle.js","sourceRoot":"","sources":["../../src/components/toggle.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,mEAAqD;AAErD,kDAAqD;AAErD,SAAS,MAAM,CACb,KAAoD;IAEpD,MAAM,KAAK,GAAG,IAAA,oBAAQ,GAAE,CAAC;IAEzB,OAAO,8BAAC,gBAAgB,IAAC,QAAQ,EAAE,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,MAAK,iBAAK,CAAC,IAAI,KAAM,KAAK,GAAI,CAAC;AAChF,CAAC;AAEQ,wBAAM"}
|
|
@@ -4,6 +4,7 @@ declare type RenderItem = React.FunctionComponent<React.HTMLProps<HTMLDivElement
|
|
|
4
4
|
['data-vlist-item-idx']: number;
|
|
5
5
|
}>;
|
|
6
6
|
declare type RenderHeader = React.FunctionComponent;
|
|
7
|
+
declare type RenderEmptyList = React.FunctionComponent;
|
|
7
8
|
declare type VirtualGridProps = {
|
|
8
9
|
itemMinWidth: number;
|
|
9
10
|
itemHeight: number;
|
|
@@ -12,6 +13,7 @@ declare type VirtualGridProps = {
|
|
|
12
13
|
renderItem: RenderItem;
|
|
13
14
|
headerHeight?: number;
|
|
14
15
|
renderHeader?: RenderHeader;
|
|
16
|
+
renderEmptyList?: RenderEmptyList;
|
|
15
17
|
overscanCount?: number;
|
|
16
18
|
classNames?: {
|
|
17
19
|
container?: string;
|
|
@@ -20,7 +22,8 @@ declare type VirtualGridProps = {
|
|
|
20
22
|
row?: string;
|
|
21
23
|
cell?: string;
|
|
22
24
|
};
|
|
25
|
+
itemKey?: (index: number) => React.Key | null | undefined;
|
|
23
26
|
};
|
|
24
|
-
export declare const VirtualGrid: React.ForwardRefExoticComponent<Pick<VirtualGridProps & Omit<React.HTMLProps<HTMLDivElement>, keyof VirtualGridProps>, "height" | "color" | "content" | "translate" | "width" | "start" | "hidden" | "default" | "cite" | "data" | "form" | "label" | "slot" | "span" | "style" | "summary" | "title" | "pattern" | "children" | "className" | "onClick" | "
|
|
27
|
+
export declare const VirtualGrid: React.ForwardRefExoticComponent<Pick<VirtualGridProps & Omit<React.HTMLProps<HTMLDivElement>, keyof VirtualGridProps>, "height" | "color" | "content" | "translate" | "width" | "start" | "hidden" | "default" | "cite" | "data" | "form" | "label" | "slot" | "span" | "style" | "summary" | "title" | "pattern" | "children" | "className" | "onClick" | "open" | "name" | "id" | "onChange" | "disabled" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "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" | "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" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "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" | "list" | "step" | "download" | "href" | "hrefLang" | "media" | "rel" | "target" | "type" | "as" | "max" | "method" | "min" | "crossOrigin" | "classID" | "useMap" | "wmode" | "cellPadding" | "cellSpacing" | "autoFocus" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "value" | "integrity" | "sizes" | "charSet" | "alt" | "coords" | "shape" | "autoPlay" | "controls" | "loop" | "mediaGroup" | "muted" | "playsInline" | "preload" | "src" | "dateTime" | "acceptCharset" | "action" | "autoComplete" | "encType" | "noValidate" | "manifest" | "allowFullScreen" | "allowTransparency" | "frameBorder" | "marginHeight" | "marginWidth" | "sandbox" | "scrolling" | "seamless" | "srcDoc" | "srcSet" | "async" | "accept" | "capture" | "checked" | "maxLength" | "minLength" | "multiple" | "readOnly" | "required" | "size" | "challenge" | "keyType" | "keyParams" | "htmlFor" | "httpEquiv" | "high" | "low" | "optimum" | "reversed" | "selected" | "defer" | "nonce" | "scoped" | "colSpan" | "headers" | "rowSpan" | "scope" | "cols" | "rows" | "wrap" | "kind" | "srcLang" | "poster" | keyof VirtualGridProps> & React.RefAttributes<HTMLDivElement>>;
|
|
25
28
|
export {};
|
|
26
29
|
//# sourceMappingURL=virtual-grid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-grid.d.ts","sourceRoot":"","sources":["../../src/components/virtual-grid.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAUf,aAAK,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AK,KAAK,CAAC,GAAG,GAAG,IAAI,GAAG,SAAS,CAAC;CAC3D,CAAC;AAsJF,eAAO,MAAM,WAAW,s5LA6FtB,CAAC"}
|
|
@@ -30,6 +30,7 @@ const GridContext = (0, react_1.createContext)({
|
|
|
30
30
|
headerHeight: 0,
|
|
31
31
|
renderHeader: () => null,
|
|
32
32
|
renderItem: () => null,
|
|
33
|
+
renderEmptyList: () => null,
|
|
33
34
|
itemsCount: 0,
|
|
34
35
|
rowCount: 0,
|
|
35
36
|
colCount: 0,
|
|
@@ -37,13 +38,15 @@ const GridContext = (0, react_1.createContext)({
|
|
|
37
38
|
gridProps: {},
|
|
38
39
|
});
|
|
39
40
|
const GridWithHeader = (0, react_1.forwardRef)(function GridHeader({ style, children, ...props }, ref) {
|
|
40
|
-
const { headerHeight, renderHeader, gridProps, classNames } = (0, react_1.useContext)(GridContext);
|
|
41
|
+
const { headerHeight, renderHeader, gridProps, classNames, renderEmptyList, itemsCount, } = (0, react_1.useContext)(GridContext);
|
|
41
42
|
return (react_1.default.createElement("div", { ref: ref, style: {
|
|
42
43
|
...style,
|
|
43
44
|
height: style.height + headerHeight,
|
|
44
45
|
}, ...props },
|
|
45
46
|
react_1.default.createElement("div", { className: classNames === null || classNames === void 0 ? void 0 : classNames.header }, react_1.default.createElement(renderHeader, {})),
|
|
46
|
-
react_1.default.createElement("div", { ...gridProps },
|
|
47
|
+
react_1.default.createElement("div", { ...gridProps }, itemsCount === 0 && renderEmptyList
|
|
48
|
+
? react_1.default.createElement(renderEmptyList, {})
|
|
49
|
+
: children)));
|
|
47
50
|
});
|
|
48
51
|
const row = (0, emotion_1.css)({
|
|
49
52
|
display: 'grid',
|
|
@@ -58,13 +61,15 @@ const cell = (0, emotion_1.css)({
|
|
|
58
61
|
minWidth: 0,
|
|
59
62
|
});
|
|
60
63
|
const Row = ({ style, index }) => {
|
|
61
|
-
const { colCount, itemsCount, renderItem, currentTabbable, classNames } = (0, react_1.useContext)(GridContext);
|
|
64
|
+
const { colCount, itemsCount, renderItem, currentTabbable, classNames, itemKey, } = (0, react_1.useContext)(GridContext);
|
|
62
65
|
const rowStart = index * colCount;
|
|
63
66
|
const cells = (0, react_1.useMemo)(() => {
|
|
64
67
|
return Array.from({ length: colCount }, (_, cellIdx) => {
|
|
68
|
+
var _a;
|
|
65
69
|
const itemIdx = rowStart + cellIdx;
|
|
66
70
|
const isEmpty = itemIdx >= itemsCount;
|
|
67
71
|
return isEmpty ? (react_1.default.createElement("div", { className: (0, emotion_1.cx)(cell, classNames === null || classNames === void 0 ? void 0 : classNames.cell), key: `empty${cellIdx}` })) : (react_1.default.createElement(renderItem, {
|
|
72
|
+
key: (_a = itemKey === null || itemKey === void 0 ? void 0 : itemKey(itemIdx)) !== null && _a !== void 0 ? _a : itemIdx,
|
|
68
73
|
role: 'gridcell',
|
|
69
74
|
className: (0, emotion_1.cx)(cell, classNames === null || classNames === void 0 ? void 0 : classNames.cell),
|
|
70
75
|
tabIndex: itemIdx === currentTabbable ? 0 : -1,
|
|
@@ -78,6 +83,7 @@ const Row = ({ style, index }) => {
|
|
|
78
83
|
itemsCount,
|
|
79
84
|
classNames === null || classNames === void 0 ? void 0 : classNames.cell,
|
|
80
85
|
renderItem,
|
|
86
|
+
itemKey,
|
|
81
87
|
currentTabbable,
|
|
82
88
|
]);
|
|
83
89
|
return (react_1.default.createElement("div", { style: style, className: (0, emotion_1.cx)(row, classNames === null || classNames === void 0 ? void 0 : classNames.row), role: "row", "aria-rowindex": index + 1 }, cells));
|
|
@@ -94,7 +100,7 @@ const container = (0, emotion_1.css)({
|
|
|
94
100
|
const grid = (0, emotion_1.css)({
|
|
95
101
|
position: 'relative',
|
|
96
102
|
});
|
|
97
|
-
exports.VirtualGrid = (0, react_1.forwardRef)(function VirtualGrid({ itemMinWidth, itemHeight, itemsCount, colCount: _colCount, renderItem, headerHeight = 0, renderHeader = () => null, overscanCount = 3, classNames, ...containerProps }, ref) {
|
|
103
|
+
exports.VirtualGrid = (0, react_1.forwardRef)(function VirtualGrid({ itemMinWidth, itemHeight, itemsCount, colCount: _colCount, renderItem, headerHeight = 0, renderHeader = () => null, renderEmptyList, overscanCount = 3, classNames, itemKey, ...containerProps }, ref) {
|
|
98
104
|
const listRef = (0, react_1.useRef)(null);
|
|
99
105
|
const [rectProps, { width: _width, height }] = (0, use_dom_rect_1.useDOMRect)();
|
|
100
106
|
const width = Math.max(_width, itemMinWidth);
|
|
@@ -129,6 +135,8 @@ exports.VirtualGrid = (0, react_1.forwardRef)(function VirtualGrid({ itemMinWidt
|
|
|
129
135
|
'aria-rowcount': rowCount,
|
|
130
136
|
className: (0, emotion_1.cx)(grid, classNames === null || classNames === void 0 ? void 0 : classNames.grid),
|
|
131
137
|
}, navigationProps, rovingFocusProps),
|
|
138
|
+
itemKey,
|
|
139
|
+
renderEmptyList,
|
|
132
140
|
} },
|
|
133
141
|
react_1.default.createElement("div", { ...gridContainerProps },
|
|
134
142
|
react_1.default.createElement(react_window_1.FixedSizeList, { ref: listRef, width: width, height: height, innerElementType: GridWithHeader, itemCount: rowCount, itemSize: itemHeight, overscanCount: overscanCount }, Row))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-grid.js","sourceRoot":"","sources":["../../src/components/virtual-grid.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,+CAOe;AACf,oDAAiD;AACjD,+CAA6C;AAC7C,wDAAmD;AACnD,gEAGmC;AACnC,sDAAkD;
|
|
1
|
+
{"version":3,"file":"virtual-grid.js","sourceRoot":"","sources":["../../src/components/virtual-grid.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,+CAOe;AACf,oDAAiD;AACjD,+CAA6C;AAC7C,wDAAmD;AACnD,gEAGmC;AACnC,sDAAkD;AAmElD,MAAM,WAAW,GAAG,IAAA,qBAAa,EAW/B;IACA,YAAY,EAAE,CAAC;IACf,YAAY,EAAE,GAAG,EAAE,CAAC,IAAI;IACxB,UAAU,EA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eAAe,EACf,gBAAgB,CACjB;YACD,OAAO;YACP,eAAe;SAChB;QAED,0CAAS,kBAAkB;YACzB,8BAAC,4BAAa,IACZ,GAAG,EAAE,OAAO,EACZ,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,cAAc,EAChC,SAAS,EAAE,QAAQ,EACnB,QAAQ,EAAE,UAAU,EACpB,aAAa,EAAE,aAAa,IAE3B,GAAG,CACU,CACZ,CACe,CACxB,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type SortOrder = 1 | -1;
|
|
3
|
+
declare type SortState<T> = {
|
|
4
|
+
name: T | null;
|
|
5
|
+
order: SortOrder;
|
|
6
|
+
};
|
|
7
|
+
declare type SortOptions = {
|
|
8
|
+
isDisabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare type Unwrap<T extends ArrayLike<unknown>> = T extends ArrayLike<infer V> ? V : never;
|
|
11
|
+
export declare function useSortControls<T extends string>(items: readonly {
|
|
12
|
+
name: T;
|
|
13
|
+
label: string;
|
|
14
|
+
}[], options?: SortOptions): [React.ReactElement, SortState<Unwrap<typeof items>['name']>];
|
|
15
|
+
export declare function useSortedItems<T extends Record<string, unknown>>(items: T[], { name, order, }: {
|
|
16
|
+
name: keyof T | null;
|
|
17
|
+
order: SortOrder;
|
|
18
|
+
}, sortFn?: Partial<{
|
|
19
|
+
[key in keyof T]: (a: T[key], b: T[key], order: SortOrder) => number;
|
|
20
|
+
}> | null): T[];
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=use-sort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-sort.d.ts","sourceRoot":"","sources":["../../src/hooks/use-sort.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAuBnD,oBAAY,SAAS,GAAG,CAAC,GAAG,CAAC,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|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.useSortedItems = exports.useSortControls = void 0;
|
|
23
|
+
const react_1 = __importStar(require("react"));
|
|
24
|
+
const utils_1 = require("@react-aria/utils");
|
|
25
|
+
const __1 = require("..");
|
|
26
|
+
const controlsContainer = (0, __1.css)({
|
|
27
|
+
display: 'flex',
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
gap: __1.spacing[2],
|
|
30
|
+
});
|
|
31
|
+
const label = (0, __1.css)({
|
|
32
|
+
margin: '0 !important',
|
|
33
|
+
padding: '0 !important',
|
|
34
|
+
});
|
|
35
|
+
const select = (0, __1.css)({
|
|
36
|
+
'& > button': {
|
|
37
|
+
margin: 0,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
function useSortControls(items, options) {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
const labelId = (0, utils_1.useId)('Sort by');
|
|
43
|
+
const controlId = (0, utils_1.useId)();
|
|
44
|
+
const [sortState, dispatch] = (0, react_1.useReducer)((state, action) => {
|
|
45
|
+
if (action.type === 'change-name' && action.name !== state.name) {
|
|
46
|
+
return {
|
|
47
|
+
...state,
|
|
48
|
+
name: action.name,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
if (action.type === 'change-order') {
|
|
52
|
+
return {
|
|
53
|
+
...state,
|
|
54
|
+
order: (state.order * -1),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return state;
|
|
58
|
+
}, { name: (_b = (_a = items[0]) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : null, order: 1 });
|
|
59
|
+
const sortControls = (0, react_1.useMemo)(() => {
|
|
60
|
+
var _a;
|
|
61
|
+
const glyph = sortState.order === -1
|
|
62
|
+
? 'SortDescending'
|
|
63
|
+
: sortState.order === 1
|
|
64
|
+
? 'SortAscending'
|
|
65
|
+
: 'Unsorted';
|
|
66
|
+
const longestLabel = Math.max(...items.map((item) => item.label.length));
|
|
67
|
+
return (react_1.default.createElement("div", { className: controlsContainer },
|
|
68
|
+
react_1.default.createElement(__1.Label, { id: labelId, htmlFor: controlId, className: label }, "Sort by"),
|
|
69
|
+
react_1.default.createElement(__1.Select, { disabled: options === null || options === void 0 ? void 0 : options.isDisabled, id: controlId, "aria-labelledby": labelId, allowDeselect: false, className: (0, __1.cx)(select, (0, __1.css)({ minWidth: `calc(${longestLabel}ch + ${__1.spacing[6]}px)` })), onChange: (value) => {
|
|
70
|
+
dispatch({ type: 'change-name', name: value || null });
|
|
71
|
+
}, defaultValue: (_a = sortState.name) !== null && _a !== void 0 ? _a : undefined }, items.map((item) => (react_1.default.createElement(__1.Option, { key: item.name, value: item.name }, item.label)))),
|
|
72
|
+
react_1.default.createElement(__1.Button, { "aria-label": glyph, title: glyph, rightGlyph: react_1.default.createElement(__1.Icon, { glyph: glyph }), onClick: () => {
|
|
73
|
+
dispatch({ type: 'change-order' });
|
|
74
|
+
}, disabled: sortState.name === null || (options === null || options === void 0 ? void 0 : options.isDisabled) })));
|
|
75
|
+
}, [sortState, items, labelId, controlId, options === null || options === void 0 ? void 0 : options.isDisabled]);
|
|
76
|
+
return [
|
|
77
|
+
sortControls,
|
|
78
|
+
(options === null || options === void 0 ? void 0 : options.isDisabled) ? { name: null, order: 1 } : sortState,
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
exports.useSortControls = useSortControls;
|
|
82
|
+
function sortUnknown(a, b, order) {
|
|
83
|
+
return (a === b ? 0 : a < b ? -1 : 1) * order;
|
|
84
|
+
}
|
|
85
|
+
function sortString(a, b, order) {
|
|
86
|
+
return a.localeCompare(b) * order;
|
|
87
|
+
}
|
|
88
|
+
function useSortedItems(items, { name, order, }, sortFn = null) {
|
|
89
|
+
return (0, react_1.useMemo)(() => {
|
|
90
|
+
return [...items].sort((a, b) => {
|
|
91
|
+
if (!name) {
|
|
92
|
+
return 0;
|
|
93
|
+
}
|
|
94
|
+
if (typeof a[name] === 'undefined') {
|
|
95
|
+
return 1;
|
|
96
|
+
}
|
|
97
|
+
const sort = sortFn && sortFn[name];
|
|
98
|
+
if (sort) {
|
|
99
|
+
return sort(a[name], b[name], order);
|
|
100
|
+
}
|
|
101
|
+
if (typeof a[name] === 'string') {
|
|
102
|
+
return sortString(a[name], b[name], order);
|
|
103
|
+
}
|
|
104
|
+
return sortUnknown(a[name], b[name], order);
|
|
105
|
+
});
|
|
106
|
+
}, [items, name, sortFn, order]);
|
|
107
|
+
}
|
|
108
|
+
exports.useSortedItems = useSortedItems;
|
|
109
|
+
//# sourceMappingURL=use-sort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-sort.js","sourceRoot":"","sources":["../../src/hooks/use-sort.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAmD;AACnD,6CAA0C;AAC1C,0BAA2E;AAE3E,MAAM,iBAAiB,GAAG,IAAA,OAAG,EAAC;IAC5B,OAAO,EAAE,MAAM;IACf,UAAU,EAAE,QAAQ;IACpB,GAAG,EAAE,WAAO,C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CAAC;aACV;YACD,MAAM,IAAI,GAAG,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;YAEpC,IAAI,IAAI,EAAE;gBACR,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;aACtC;YAED,IAAI,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,QAAQ,EAAE;gBAC/B,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAW,EAAE,CAAC,CAAC,IAAI,CAAW,EAAE,KAAK,CAAC,CAAC;aAChE;YACD,OAAO,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AACnC,CAAC;AArCD,wCAqCC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare enum Theme {
|
|
3
|
+
Light = "Light",
|
|
4
|
+
Dark = "Dark"
|
|
5
|
+
}
|
|
6
|
+
declare type ThemeState = {
|
|
7
|
+
theme: Theme;
|
|
8
|
+
};
|
|
9
|
+
declare const ThemeProvider: ({ children, theme, }: {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
theme: ThemeState;
|
|
12
|
+
}) => React.ReactElement;
|
|
13
|
+
declare function useTheme(): ThemeState;
|
|
14
|
+
export { useTheme, ThemeProvider };
|
|
15
|
+
//# sourceMappingURL=use-theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-theme.d.ts","sourceRoot":"","sources":["../../src/hooks/use-theme.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAEzD,oBAAY,KAAK;IACf,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAED,aAAK,UAAU,GAAG;IAChB,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAMF,QAAA,MAAM,aAAa;cAIP,MAAM,SAAS;WAClB,UAAU;MACf,MAAM,YAIT,CAAC;AAEF,iBAAS,QAAQ,IAAI,UAAU,CAE9B;AAED,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.ThemeProvider = exports.useTheme = exports.Theme = void 0;
|
|
23
|
+
const react_1 = __importStar(require("react"));
|
|
24
|
+
var Theme;
|
|
25
|
+
(function (Theme) {
|
|
26
|
+
Theme["Light"] = "Light";
|
|
27
|
+
Theme["Dark"] = "Dark";
|
|
28
|
+
})(Theme = exports.Theme || (exports.Theme = {}));
|
|
29
|
+
const ThemeContext = (0, react_1.createContext)({
|
|
30
|
+
theme: Theme.Light,
|
|
31
|
+
});
|
|
32
|
+
const ThemeProvider = ({ children, theme, }) => {
|
|
33
|
+
return (react_1.default.createElement(ThemeContext.Provider, { value: theme }, children));
|
|
34
|
+
};
|
|
35
|
+
exports.ThemeProvider = ThemeProvider;
|
|
36
|
+
function useTheme() {
|
|
37
|
+
return (0, react_1.useContext)(ThemeContext);
|
|
38
|
+
}
|
|
39
|
+
exports.useTheme = useTheme;
|
|
40
|
+
//# sourceMappingURL=use-theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-theme.js","sourceRoot":"","sources":["../../src/hooks/use-theme.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAyD;AAEzD,IAAY,KAGX;AAHD,WAAY,KAAK;IACf,wBAAe,CAAA;IACf,sBAAa,CAAA;AACf,CAAC,EAHW,KAAK,GAAL,aAAK,KAAL,aAAK,QAGhB;AAMD,MAAM,YAAY,GAAG,IAAA,qBAAa,EAAa;IAC7C,KAAK,EAAE,KAAK,CAAC,KAAK;CACnB,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,CAAC,EACrB,QAAQ,EACR,KAAK,GAIN,EAAsB,EAAE;IACvB,OAAO,CACL,8BAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IAAG,QAAQ,CAAyB,CACxE,CAAC;AACJ,CAAC,CAAC;AAMiB,sCAAa;AAJhC,SAAS,QAAQ;IACf,OAAO,IAAA,kBAAU,EAAC,YAAY,CAAC,CAAC;AAClC,CAAC;AAEQ,4BAAQ"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ToastVariant } from '..';
|
|
3
|
+
declare type ToastProperties = {
|
|
4
|
+
title?: React.ReactNode;
|
|
5
|
+
body: React.ReactNode;
|
|
6
|
+
variant: ToastVariant;
|
|
7
|
+
progress?: number;
|
|
8
|
+
timeout?: number;
|
|
9
|
+
};
|
|
10
|
+
interface ToastActions {
|
|
11
|
+
openToast: (id: string, toastProperties: ToastProperties) => void;
|
|
12
|
+
closeToast: (id: string) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const ToastArea: React.FunctionComponent;
|
|
15
|
+
export declare function useToast(namespace: string): ToastActions;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=use-toast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-toast.d.ts","sourceRoot":"","sources":["../../src/hooks/use-toast.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAIvC,aAAK,eAAe,GAAG;IACrB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,UAAU,YAAY;IACpB,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,KAAK,IAAI,CAAC;IAClE,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAgCD,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,iBAoF7B,CAAC;AAEF,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,YAAY,CAsBxD"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.useToast = exports.ToastArea = void 0;
|
|
23
|
+
const react_1 = __importStar(require("react"));
|
|
24
|
+
const __1 = require("..");
|
|
25
|
+
const __2 = require("..");
|
|
26
|
+
const ToastContext = (0, react_1.createContext)({
|
|
27
|
+
openToast: () => {
|
|
28
|
+
},
|
|
29
|
+
closeToast: () => {
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
const toastStyles = (0, __1.css)({
|
|
33
|
+
button: {
|
|
34
|
+
position: 'absolute',
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
const ToastArea = ({ children }) => {
|
|
38
|
+
const [toasts, setToasts] = (0, react_1.useState)({});
|
|
39
|
+
const timeouts = (0, react_1.useRef)({});
|
|
40
|
+
(0, react_1.useEffect)(() => {
|
|
41
|
+
return () => {
|
|
42
|
+
Object.values(timeouts).forEach(clearTimeout);
|
|
43
|
+
};
|
|
44
|
+
}, [timeouts]);
|
|
45
|
+
const clearTimeoutRef = (0, react_1.useCallback)((id) => {
|
|
46
|
+
clearTimeout(timeouts.current[id]);
|
|
47
|
+
delete timeouts.current[id];
|
|
48
|
+
}, [timeouts]);
|
|
49
|
+
const setTimeoutRef = (0, react_1.useCallback)((id, callback, timeout) => {
|
|
50
|
+
clearTimeoutRef(id);
|
|
51
|
+
timeouts.current[id] = setTimeout(callback, timeout);
|
|
52
|
+
}, [timeouts, clearTimeoutRef]);
|
|
53
|
+
const closeToast = (0, react_1.useCallback)((toastId) => {
|
|
54
|
+
clearTimeoutRef(toastId);
|
|
55
|
+
setToasts((prevToasts) => {
|
|
56
|
+
const newToasts = { ...prevToasts };
|
|
57
|
+
delete newToasts[toastId];
|
|
58
|
+
return newToasts;
|
|
59
|
+
});
|
|
60
|
+
}, [setToasts, clearTimeoutRef]);
|
|
61
|
+
const openToast = (0, react_1.useCallback)((toastId, toastProperties) => {
|
|
62
|
+
clearTimeoutRef(toastId);
|
|
63
|
+
if (toastProperties.timeout) {
|
|
64
|
+
setTimeoutRef(toastId, () => {
|
|
65
|
+
closeToast(toastId);
|
|
66
|
+
}, toastProperties.timeout);
|
|
67
|
+
}
|
|
68
|
+
setToasts((prevToasts) => ({
|
|
69
|
+
...prevToasts,
|
|
70
|
+
[toastId]: {
|
|
71
|
+
...toastProperties,
|
|
72
|
+
},
|
|
73
|
+
}));
|
|
74
|
+
}, [setToasts, setTimeoutRef, clearTimeoutRef, closeToast]);
|
|
75
|
+
return (react_1.default.createElement(ToastContext.Provider, { value: { closeToast, openToast } },
|
|
76
|
+
react_1.default.createElement(react_1.default.Fragment, null, children),
|
|
77
|
+
react_1.default.createElement(react_1.default.Fragment, null, Object.entries(toasts).map(([id, { title, body, variant, progress }]) => (react_1.default.createElement(__2.Toast, { className: toastStyles, key: id, title: title, body: body, variant: variant, progress: progress, open: true, close: () => closeToast(id) }))))));
|
|
78
|
+
};
|
|
79
|
+
exports.ToastArea = ToastArea;
|
|
80
|
+
function useToast(namespace) {
|
|
81
|
+
const { openToast: openGlobalToast, closeToast: closeGlobalToast } = (0, react_1.useContext)(ToastContext);
|
|
82
|
+
const openToast = (0, react_1.useCallback)((toastId, toastProperties) => {
|
|
83
|
+
openGlobalToast(`${namespace}--${toastId}`, toastProperties);
|
|
84
|
+
}, [namespace, openGlobalToast]);
|
|
85
|
+
const closeToast = (0, react_1.useCallback)((toastId) => {
|
|
86
|
+
closeGlobalToast(`${namespace}--${toastId}`);
|
|
87
|
+
}, [namespace, closeGlobalToast]);
|
|
88
|
+
return {
|
|
89
|
+
openToast,
|
|
90
|
+
closeToast,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
exports.useToast = useToast;
|
|
94
|
+
//# sourceMappingURL=use-toast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-toast.js","sourceRoot":"","sources":["../../src/hooks/use-toast.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,+CAOe;AAEf,0BAAyB;AACzB,0BAA2B;AAe3B,MAAM,YAAY,GAAG,IAAA,qBAAa,EAAe;IAC/C,SAAS,EAAE,GAAG,EAAE;IAEhB,CAAC;IACD,UAAU,EAAE,GAAG,EAAE;IAEjB,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,IAAA,OAAG,EAAC;IACtB,MAAM,EAAE;QACN,QAAQ,EAAE,UAAU;KACrB;CACF,CAAC,CAAC;AAiBI,MAAM,SAAS,GAA4B,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IACjE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAkC,EAAE,CAAC,CAAC;IAC1E,MAAM,QAAQ,GAAG,IAAA,cAAM,EAAgD,EAAE,CAAC,CAAC;IAE3E,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAChD,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,MAAM,eAAe,GAAG,IAAA,mBAAW,EACjC,CAAC,EAAE,EAAE,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