@fibery/ui-kit 9.1.2 → 9.2.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/actions-menu/actions-menu-item.js +1 -1
- package/lib/actions-menu/actions-menu-sub-command-menu.js +2 -2
- package/lib/actions-menu/contexts/actions-menu-context.js +2 -2
- package/lib/actions-menu/contexts/actions-menu-dangerous-rows.js +3 -3
- package/lib/antd/input.d.ts +1 -1
- package/lib/automation-avatar.d.ts +8 -0
- package/lib/automation-avatar.js +43 -0
- package/lib/board-table-loader.js +7 -7
- package/lib/card-container.js +1 -1
- package/lib/comment.js +3 -3
- package/lib/design-system/colors.d.ts +4 -4
- package/lib/design-system/colors.js +6 -6
- package/lib/design-system/skeleton.d.ts +7 -0
- package/lib/design-system/skeleton.js +18 -0
- package/lib/design-system.d.ts +2 -1
- package/lib/design-system.js +2 -1
- package/lib/emoji-picker/primitives/content.js +2 -2
- package/lib/emoji-picker/primitives/preview-provider.js +3 -3
- package/lib/emoji-picker/primitives/root.js +3 -3
- package/lib/emoji-picker/primitives/search-provider.js +3 -3
- package/lib/emoji-picker/primitives/skin-provider.js +3 -3
- package/lib/emoji-picker/stores/emoji-data-store.js +2 -2
- package/lib/file-item/file-preview-actions.js +1 -1
- package/lib/file-item.js +14 -14
- package/lib/file-item.wyw-in-js.css +10 -11
- package/lib/icons/ast/index.d.ts +4 -1
- package/lib/icons/ast/index.js +4 -1
- package/lib/icons/ast/integration-claude.d.ts +5 -0
- package/lib/icons/ast/integration-claude.js +25 -0
- package/lib/icons/ast/integration-gemini.d.ts +5 -0
- package/lib/icons/ast/integration-gemini.js +25 -0
- package/lib/icons/ast/integration-openai.d.ts +5 -0
- package/lib/icons/ast/integration-openai.js +25 -0
- package/lib/icons/react/index.d.ts +4 -1
- package/lib/icons/react/index.js +4 -1
- package/lib/icons/react/integration-claude.d.ts +15 -0
- package/lib/icons/react/integration-claude.js +21 -0
- package/lib/icons/react/integration-gemini.d.ts +15 -0
- package/lib/icons/react/integration-gemini.js +21 -0
- package/lib/icons/react/integration-openai.d.ts +15 -0
- package/lib/icons/react/integration-openai.js +21 -0
- package/lib/images-gallery/images-gallery.js +4 -4
- package/lib/loaders.js +7 -11
- package/lib/number-input/number-input.js +13 -5
- package/lib/open-popover-tracker.js +2 -2
- package/lib/popover/index.js +2 -2
- package/lib/popover/mobile-popover-context.js +2 -2
- package/lib/popover/popup-stack-context.js +2 -2
- package/lib/random.d.ts +4 -0
- package/lib/random.js +11 -0
- package/lib/rich-input-loader.js +7 -13
- package/lib/rich-input-loader.wyw-in-js.css +2 -3
- package/lib/root-theme-provider.wyw-in-js.css +1 -1
- package/lib/scroll-fade.d.ts +6 -0
- package/lib/scroll-fade.js +16 -0
- package/lib/scroll-fade.wyw-in-js.css +13 -0
- package/lib/select/index.js +4 -3
- package/lib/select/index.wyw-in-js.css +3 -3
- package/lib/select/select-control-settings-context.d.ts +3 -1
- package/lib/select/select-control-settings-context.js +5 -3
- package/lib/select/select-in-popover.js +2 -0
- package/lib/select/select-loader.js +2 -2
- package/lib/skeleton-card.d.ts +7 -0
- package/lib/skeleton-card.js +16 -0
- package/lib/skeleton-card.wyw-in-js.css +2 -0
- package/lib/skeleton.d.ts +45 -0
- package/lib/skeleton.js +58 -0
- package/lib/skeleton.wyw-in-js.css +6 -0
- package/lib/spinner-box.d.ts +12 -0
- package/lib/spinner-box.js +23 -0
- package/lib/spinner-box.wyw-in-js.css +2 -0
- package/lib/tab-nav/tab-nav.js +3 -3
- package/lib/theming.generated.d.ts +8 -8
- package/lib/theming.generated.js +8 -8
- package/lib/toast/toast-provider.js +2 -2
- package/lib/tree-utils.d.ts +11 -19
- package/lib/unit/loading-unit-value.d.ts +3 -4
- package/lib/unit/loading-unit-value.js +3 -4
- package/lib/unit/maybe-unit-value.js +1 -4
- package/lib/unit/nav-button.d.ts +1 -0
- package/lib/unit/nav-button.js +8 -5
- package/lib/use-is-phone.js +2 -2
- package/lib/use-on-screen-keyboard-data.js +3 -3
- package/package.json +3 -6
- package/lib/ai/model.d.ts +0 -8
- package/lib/ai/model.js +0 -55
- package/lib/ai/model.wyw-in-js.css +0 -1
- package/lib/antd/auto-width-transparent-textarea.d.ts +0 -8
- package/lib/antd/auto-width-transparent-textarea.js +0 -34
- package/lib/antd/auto-width-transparent-textarea.wyw-in-js.css +0 -2
- package/lib/get-trigger-node-popup-container.d.ts +0 -4
- package/lib/get-trigger-node-popup-container.js +0 -8
- package/lib/lists/actions-menu-row-surface.d.ts +0 -12
- package/lib/lists/actions-menu-row-surface.js +0 -65
- package/lib/lists/actions-menu-row-surface.wyw-in-js.css +0 -4
- package/lib/loading-sausage.d.ts +0 -24
- package/lib/loading-sausage.js +0 -54
- package/lib/loading-sausage.wyw-in-js.css +0 -4
- package/lib/nested-menu-item.d.ts +0 -1
- package/lib/nested-menu-item.js +0 -0
- package/lib/not-empty.d.ts +0 -4
- package/lib/not-empty.js +0 -6
- package/lib/use-why-did-you-update.d.ts +0 -4
- package/lib/use-why-did-you-update.js +0 -25
- package/lib/with-data.d.ts +0 -77
- package/lib/with-data.js +0 -55
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import "./actions-menu-row-surface.wyw-in-js.css";
|
|
2
|
-
import { textClasses } from "../design-system/typography.js";
|
|
3
|
-
import { useIsSupportHover } from "../use-is-support-hover.js";
|
|
4
|
-
import { useActionsMenuContext } from "../actions-menu/contexts/actions-menu-context.js";
|
|
5
|
-
import { useActiveDangerousRow, useSetActiveDangerousRow } from "../actions-menu/contexts/actions-menu-dangerous-rows.js";
|
|
6
|
-
import { ListRowContent, listRowSurfaceStylesBase } from "./list-row-surface.js";
|
|
7
|
-
/* empty css */
|
|
8
|
-
import { noop } from "@fibery/helpers/src/_";
|
|
9
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { forwardRef, useId } from "react";
|
|
11
|
-
import { cx } from "@linaria/core";
|
|
12
|
-
import { stopPropagation } from "@fibery/react/src/stop-propagation";
|
|
13
|
-
import { useCallbackRef } from "@fibery/react/src/use-callback-ref";
|
|
14
|
-
//#region src/lists/actions-menu-row-surface.tsx
|
|
15
|
-
var actionMenuItemSurface = "a17pn820-actionMenuItemSurface";
|
|
16
|
-
var ActionMenuItemSurface = forwardRef(({ testId, className, loading, selected, hovered, focused, title, disabled, children, dangerous, ...props }, ref) => {
|
|
17
|
-
const id = useId();
|
|
18
|
-
const platformSupportsHover = useIsSupportHover();
|
|
19
|
-
const showWarning = useActiveDangerousRow() === id;
|
|
20
|
-
const onSelect = useCallbackRef(props.onSelect || noop);
|
|
21
|
-
const { MenuPrimitive } = useActionsMenuContext();
|
|
22
|
-
const setActiveDangerousRow = useSetActiveDangerousRow();
|
|
23
|
-
const handleSelect = (e) => {
|
|
24
|
-
e.stopPropagation();
|
|
25
|
-
if (loading || !id) {
|
|
26
|
-
e.preventDefault();
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
if (dangerous && !showWarning) {
|
|
30
|
-
e.preventDefault();
|
|
31
|
-
setActiveDangerousRow(id);
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
setActiveDangerousRow(null);
|
|
35
|
-
onSelect(e);
|
|
36
|
-
};
|
|
37
|
-
return /* @__PURE__ */ jsx(MenuPrimitive.Item, {
|
|
38
|
-
ref,
|
|
39
|
-
"data-testid": testId,
|
|
40
|
-
onClick: stopPropagation,
|
|
41
|
-
onSelect: handleSelect,
|
|
42
|
-
title: title ? title : "",
|
|
43
|
-
className: cx(listRowSurfaceStylesBase, actionMenuItemSurface, className, platformSupportsHover && hovered === void 0 && "natural-hover", focused === void 0 && "natural-focus", focused && "focus", disabled && "done", selected && "selected", dangerous && "dangerous", showWarning && "warn"),
|
|
44
|
-
disabled,
|
|
45
|
-
children
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
var actionMenuItemDescriptionClass = "a11chqvq-actionMenuItemDescription";
|
|
49
|
-
var actionMenuItemContentClass = "aw0iqns-actionMenuItemContent";
|
|
50
|
-
var actionMenuItemWithDescription = "aldd35y-actionMenuItemWithDescription";
|
|
51
|
-
var ActionMenuItemContent = forwardRef(({ contentClassName, description, ...rest }, ref) => {
|
|
52
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
53
|
-
className: cx(description && actionMenuItemWithDescription),
|
|
54
|
-
children: [/* @__PURE__ */ jsx(ListRowContent, {
|
|
55
|
-
contentClassName: cx(contentClassName, actionMenuItemContentClass),
|
|
56
|
-
ref,
|
|
57
|
-
...rest
|
|
58
|
-
}), description ? /* @__PURE__ */ jsx("div", {
|
|
59
|
-
className: cx(textClasses.small, actionMenuItemDescriptionClass),
|
|
60
|
-
children: description
|
|
61
|
-
}) : null]
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
//#endregion
|
|
65
|
-
export { ActionMenuItemContent, ActionMenuItemSurface, actionMenuItemSurface };
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
.a17pn820-actionMenuItemSurface{margin:0 4px;background-color:var(--colorBgListItemGeneral);}.a17pn820-actionMenuItemSurface.natural-hover:hover,.a17pn820-actionMenuItemSurface[data-highlighted]{background-color:var(--colorBgActionsMenuItemHover);}.a17pn820-actionMenuItemSurface.done,.a17pn820-actionMenuItemSurface[data-disabled]{cursor:not-allowed;color:var(--colorTextListItemGeneralDisabled);background-color:var(--colorBgListItemGeneralDisabled);}.a17pn820-actionMenuItemSurface.done.natural-hover:hover,.a17pn820-actionMenuItemSurface[data-disabled].natural-hover:hover,.a17pn820-actionMenuItemSurface.done.hover>*,.a17pn820-actionMenuItemSurface[data-disabled].hover>*{opacity:var(--opacityListItemGeneralDisabled);}.a17pn820-actionMenuItemSurface.selected{cursor:default;background-color:var(--colorBgActionsMenuItemSelected);}.a17pn820-actionMenuItemSurface.selected.natural-hover:hover,.a17pn820-actionMenuItemSurface.selected.hover,.a17pn820-actionMenuItemSurface.selected[data-highlighted]{background-color:var(--colorBgActionsMenuItemSelectedHover);}.a17pn820-actionMenuItemSurface.dangerous{background-color:var(--colorBgActionsMenuItemDangerActive);}.a17pn820-actionMenuItemSurface.dangerous.natural-hover:hover,.a17pn820-actionMenuItemSurface.dangerous.hover,.a17pn820-actionMenuItemSurface.dangerous[data-highlighted]{background-color:var(--colorBgActionsMenuItemDangerActive);}.a17pn820-actionMenuItemSurface.warm{background-color:var(--colorBgActionsMenuItemDangerActive);color:var(--whiteColor);}.a17pn820-actionMenuItemSurface.warm.natural-hover:hover,.a17pn820-actionMenuItemSurface.warm.hover,.a17pn820-actionMenuItemSurface.warm[data-highlighted]{background-color:var(--colorBgActionsMenuItemDangerActive);color:var(--whiteColor);}
|
|
2
|
-
.a11chqvq-actionMenuItemDescription{line-height:1;color:var(--accentTextColor);padding:2px 8px 0;}
|
|
3
|
-
.aw0iqns-actionMenuItemContent{line-height:32px;padding:0 8px;}
|
|
4
|
-
.aldd35y-actionMenuItemWithDescription{min-height:52px;}
|
package/lib/loading-sausage.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ComponentType, ReactNode } from "react";
|
|
2
|
-
//#region src/loading-sausage.d.ts
|
|
3
|
-
declare const getRandomInt: (min: number, max: number, seed?: number) => number;
|
|
4
|
-
type LoadingSausageProps = {
|
|
5
|
-
minWidth?: number;
|
|
6
|
-
maxWidth?: number;
|
|
7
|
-
height?: number;
|
|
8
|
-
inverted?: boolean;
|
|
9
|
-
animateAppearance?: boolean;
|
|
10
|
-
margins?: boolean;
|
|
11
|
-
index?: number;
|
|
12
|
-
};
|
|
13
|
-
declare const LoadingSausage: import("react").MemoExoticComponent<({ minWidth, maxWidth, index, height, margins, animateAppearance }: LoadingSausageProps) => JSX.Element>;
|
|
14
|
-
type SausageListProps = {
|
|
15
|
-
amount?: number;
|
|
16
|
-
minAmount?: number;
|
|
17
|
-
maxAmount?: number;
|
|
18
|
-
WrapperComponent?: ComponentType<{
|
|
19
|
-
children: ReactNode;
|
|
20
|
-
}> | null;
|
|
21
|
-
} & Omit<LoadingSausageProps, "index">;
|
|
22
|
-
declare const LoadingSausageList: import("react").NamedExoticComponent<SausageListProps>;
|
|
23
|
-
//#endregion
|
|
24
|
-
export { LoadingSausage, LoadingSausageList, LoadingSausageProps, getRandomInt };
|
package/lib/loading-sausage.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import "./loading-sausage.wyw-in-js.css";
|
|
2
|
-
/* empty css */
|
|
3
|
-
import { Fragment, jsx } from "react/jsx-runtime";
|
|
4
|
-
import { memo, useState } from "react";
|
|
5
|
-
import cx from "classnames";
|
|
6
|
-
import { styled } from "@linaria/react";
|
|
7
|
-
//#region src/loading-sausage.tsx
|
|
8
|
-
var getRandomWithSeed = (seed) => {
|
|
9
|
-
const x = Math.sin(seed + 1) * 1e4;
|
|
10
|
-
return x - Math.floor(x);
|
|
11
|
-
};
|
|
12
|
-
var getRandomInt = (min, max, seed) => {
|
|
13
|
-
const random = seed !== void 0 ? getRandomWithSeed(seed) : Math.random();
|
|
14
|
-
return Math.floor(random * (max - min + 1)) + min;
|
|
15
|
-
};
|
|
16
|
-
var loadingSausageStyle = "l16t34ge-loadingSausage";
|
|
17
|
-
var marginStyle = "m9y52vn-margin";
|
|
18
|
-
var loadingSausageWithAnimatedAppearanceStyle = "l13a41xq-loadingSausageWithAnimatedAppearance";
|
|
19
|
-
var _exp4 = () => ((props) => `${props.height / 2}px`);
|
|
20
|
-
var Container = /*#__PURE__*/ styled("div")({
|
|
21
|
-
name: "Container",
|
|
22
|
-
class: "c1pjyqzf-Container",
|
|
23
|
-
propsAsIs: false,
|
|
24
|
-
vars: { "c1pjyqzf-0": [_exp4()] }
|
|
25
|
-
});
|
|
26
|
-
var LoadingSausage = memo(function LoadingSausage({ minWidth = 80, maxWidth = 120, index, height = 12, margins = true, animateAppearance = false }) {
|
|
27
|
-
const [width] = useState(() => getRandomInt(minWidth, maxWidth, index));
|
|
28
|
-
return /* @__PURE__ */ jsx(Container, {
|
|
29
|
-
height,
|
|
30
|
-
style: {
|
|
31
|
-
width,
|
|
32
|
-
height
|
|
33
|
-
},
|
|
34
|
-
className: cx(loadingSausageStyle, margins && marginStyle, animateAppearance && loadingSausageWithAnimatedAppearanceStyle)
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
var LoadingSausageList = memo(function LoadingSausageList({ amount, minAmount = 1, maxAmount = 1, WrapperComponent, ...restProps }) {
|
|
38
|
-
const calculatedAmount = amount || getRandomInt(minAmount, maxAmount);
|
|
39
|
-
return /* @__PURE__ */ jsx(Fragment, { children: Array.from({ length: calculatedAmount }, (_, index) => {
|
|
40
|
-
const style = { opacity: (calculatedAmount - index) / calculatedAmount };
|
|
41
|
-
return /* @__PURE__ */ jsx("div", {
|
|
42
|
-
style,
|
|
43
|
-
children: WrapperComponent ? /* @__PURE__ */ jsx(WrapperComponent, { children: /* @__PURE__ */ jsx(LoadingSausage, {
|
|
44
|
-
index: index + 1,
|
|
45
|
-
...restProps
|
|
46
|
-
}) }) : /* @__PURE__ */ jsx(LoadingSausage, {
|
|
47
|
-
index: index + 1,
|
|
48
|
-
...restProps
|
|
49
|
-
})
|
|
50
|
-
}, index);
|
|
51
|
-
}) });
|
|
52
|
-
});
|
|
53
|
-
//#endregion
|
|
54
|
-
export { LoadingSausage, LoadingSausageList, getRandomInt };
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
.l16t34ge-loadingSausage{vertical-align:middle;position:relative;background:none;}.l16t34ge-loadingSausage::before,.l16t34ge-loadingSausage::after{content:"";display:block;position:absolute;top:0;bottom:0;left:0;right:0;}@keyframes OpacityAnim-l16t34ge-loadingSausage{0%{opacity:1;}100%{opacity:0;}}.l16t34ge-loadingSausage::before{background-image:linear-gradient(90deg, transparent 0%, var(--colorBgSkeleton) 100%);animation:OpacityAnim-l16t34ge-loadingSausage 2s ease-in-out 0s infinite alternate;}.l16t34ge-loadingSausage::after{background-image:linear-gradient(90deg, var(--colorBgSkeleton) 0%, transparent 100%);animation:OpacityAnim-l16t34ge-loadingSausage 2s ease-in-out -2s infinite alternate;}
|
|
2
|
-
.m9y52vn-margin{margin-top:4px;margin-bottom:4px;}
|
|
3
|
-
.l13a41xq-loadingSausageWithAnimatedAppearance{animation:OpacityAnim-l13a41xq-loadingSausageWithAnimatedAppearance 1s cubic-bezier(0.95, 0.05, 0.795, 0.035) 1;}@keyframes OpacityAnim-l13a41xq-loadingSausageWithAnimatedAppearance{0%{opacity:0;}100%{opacity:1;}}
|
|
4
|
-
.c1pjyqzf-Container::before,.c1pjyqzf-Container::after{border-radius:var(--c1pjyqzf-0);}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|
package/lib/nested-menu-item.js
DELETED
|
File without changes
|
package/lib/not-empty.d.ts
DELETED
package/lib/not-empty.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
//#region src/use-why-did-you-update.tsx
|
|
3
|
-
function useWhyDidYouUpdate(name, props) {
|
|
4
|
-
const previousProps = useRef();
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
const current = previousProps.current;
|
|
7
|
-
if (current) {
|
|
8
|
-
const allKeys = Object.keys({
|
|
9
|
-
...current,
|
|
10
|
-
...props
|
|
11
|
-
});
|
|
12
|
-
const changesObj = {};
|
|
13
|
-
allKeys.forEach((key) => {
|
|
14
|
-
if (current[key] !== props[key]) changesObj[key] = {
|
|
15
|
-
from: current[key],
|
|
16
|
-
to: props[key]
|
|
17
|
-
};
|
|
18
|
-
});
|
|
19
|
-
if (Object.keys(changesObj).length) console.log("[why-did-you-update]", name, changesObj);
|
|
20
|
-
}
|
|
21
|
-
previousProps.current = props;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
//#endregion
|
|
25
|
-
export { useWhyDidYouUpdate as default };
|
package/lib/with-data.d.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { ComponentType } from "react";
|
|
2
|
-
//#region src/with-data.d.ts
|
|
3
|
-
type FetchState<Value = unknown> = {
|
|
4
|
-
fetchState: ":fetch-state/start";
|
|
5
|
-
fetchError: null;
|
|
6
|
-
fetchValue: null;
|
|
7
|
-
} | {
|
|
8
|
-
fetchState: ":fetch-state/success";
|
|
9
|
-
fetchValue: Value;
|
|
10
|
-
fetchError: null;
|
|
11
|
-
} | {
|
|
12
|
-
fetchState: ":fetch-state/error";
|
|
13
|
-
fetchError: Error;
|
|
14
|
-
fetchValue: null;
|
|
15
|
-
};
|
|
16
|
-
type DataSources = Record<string, () => Promise<unknown>>;
|
|
17
|
-
type ProvidedState<Sources extends DataSources> = { [Key in keyof Sources]: FetchState<Awaited<ReturnType<Sources[Key]>>>; };
|
|
18
|
-
declare function provideData<Sources extends DataSources>({ sources }: {
|
|
19
|
-
sources: Sources;
|
|
20
|
-
}): <OwnProps extends object>(Component: ComponentType<OwnProps & ProvidedState<Sources>>) => {
|
|
21
|
-
new (props: OwnProps): {
|
|
22
|
-
state: ProvidedState<Sources>;
|
|
23
|
-
_prefetch: <Key extends keyof Sources>(key: Key, fetch: Sources[Key]) => Promise<void>;
|
|
24
|
-
setSourceState<Key extends keyof Sources>(key: Key, value: ProvidedState<Sources>[Key]): void;
|
|
25
|
-
componentDidMount(): void;
|
|
26
|
-
setStateIfMounted(updater: (prevState: ProvidedState<Sources>) => ProvidedState<Sources>): void;
|
|
27
|
-
componentWillUnmount(): void;
|
|
28
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
29
|
-
context: unknown;
|
|
30
|
-
setState<K extends keyof Sources>(state: Pick<ProvidedState<Sources>, K> | ProvidedState<Sources> | ((prevState: Readonly<ProvidedState<Sources>>, props: Readonly<OwnProps>) => Pick<ProvidedState<Sources>, K> | ProvidedState<Sources> | null) | null, callback?: (() => void) | undefined): void;
|
|
31
|
-
forceUpdate(callback?: (() => void) | undefined): void;
|
|
32
|
-
readonly props: Readonly<OwnProps>;
|
|
33
|
-
refs: {
|
|
34
|
-
[key: string]: import("react").ReactInstance;
|
|
35
|
-
};
|
|
36
|
-
shouldComponentUpdate?(nextProps: Readonly<OwnProps>, nextState: Readonly<ProvidedState<Sources>>, nextContext: any): boolean;
|
|
37
|
-
componentDidCatch?(error: Error, errorInfo: import("react").ErrorInfo): void;
|
|
38
|
-
getSnapshotBeforeUpdate?(prevProps: Readonly<OwnProps>, prevState: Readonly<ProvidedState<Sources>>): any;
|
|
39
|
-
componentDidUpdate?(prevProps: Readonly<OwnProps>, prevState: Readonly<ProvidedState<Sources>>, snapshot?: any): void;
|
|
40
|
-
componentWillMount?(): void;
|
|
41
|
-
UNSAFE_componentWillMount?(): void;
|
|
42
|
-
componentWillReceiveProps?(nextProps: Readonly<OwnProps>, nextContext: any): void;
|
|
43
|
-
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<OwnProps>, nextContext: any): void;
|
|
44
|
-
componentWillUpdate?(nextProps: Readonly<OwnProps>, nextState: Readonly<ProvidedState<Sources>>, nextContext: any): void;
|
|
45
|
-
UNSAFE_componentWillUpdate?(nextProps: Readonly<OwnProps>, nextState: Readonly<ProvidedState<Sources>>, nextContext: any): void;
|
|
46
|
-
};
|
|
47
|
-
new (props: OwnProps, context: any): {
|
|
48
|
-
state: ProvidedState<Sources>;
|
|
49
|
-
_prefetch: <Key extends keyof Sources>(key: Key, fetch: Sources[Key]) => Promise<void>;
|
|
50
|
-
setSourceState<Key extends keyof Sources>(key: Key, value: ProvidedState<Sources>[Key]): void;
|
|
51
|
-
componentDidMount(): void;
|
|
52
|
-
setStateIfMounted(updater: (prevState: ProvidedState<Sources>) => ProvidedState<Sources>): void;
|
|
53
|
-
componentWillUnmount(): void;
|
|
54
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
55
|
-
context: unknown;
|
|
56
|
-
setState<K extends keyof Sources>(state: Pick<ProvidedState<Sources>, K> | ProvidedState<Sources> | ((prevState: Readonly<ProvidedState<Sources>>, props: Readonly<OwnProps>) => Pick<ProvidedState<Sources>, K> | ProvidedState<Sources> | null) | null, callback?: (() => void) | undefined): void;
|
|
57
|
-
forceUpdate(callback?: (() => void) | undefined): void;
|
|
58
|
-
readonly props: Readonly<OwnProps>;
|
|
59
|
-
refs: {
|
|
60
|
-
[key: string]: import("react").ReactInstance;
|
|
61
|
-
};
|
|
62
|
-
shouldComponentUpdate?(nextProps: Readonly<OwnProps>, nextState: Readonly<ProvidedState<Sources>>, nextContext: any): boolean;
|
|
63
|
-
componentDidCatch?(error: Error, errorInfo: import("react").ErrorInfo): void;
|
|
64
|
-
getSnapshotBeforeUpdate?(prevProps: Readonly<OwnProps>, prevState: Readonly<ProvidedState<Sources>>): any;
|
|
65
|
-
componentDidUpdate?(prevProps: Readonly<OwnProps>, prevState: Readonly<ProvidedState<Sources>>, snapshot?: any): void;
|
|
66
|
-
componentWillMount?(): void;
|
|
67
|
-
UNSAFE_componentWillMount?(): void;
|
|
68
|
-
componentWillReceiveProps?(nextProps: Readonly<OwnProps>, nextContext: any): void;
|
|
69
|
-
UNSAFE_componentWillReceiveProps?(nextProps: Readonly<OwnProps>, nextContext: any): void;
|
|
70
|
-
componentWillUpdate?(nextProps: Readonly<OwnProps>, nextState: Readonly<ProvidedState<Sources>>, nextContext: any): void;
|
|
71
|
-
UNSAFE_componentWillUpdate?(nextProps: Readonly<OwnProps>, nextState: Readonly<ProvidedState<Sources>>, nextContext: any): void;
|
|
72
|
-
};
|
|
73
|
-
contextType?: import("react").Context<any> | undefined;
|
|
74
|
-
};
|
|
75
|
-
declare const DefaultDependenciesLoader: () => import("react/jsx-runtime").JSX.Element;
|
|
76
|
-
//#endregion
|
|
77
|
-
export { DefaultDependenciesLoader, provideData };
|
package/lib/with-data.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { asError } from "./errors.js";
|
|
2
|
-
import { mapValues, noop } from "@fibery/helpers/src/_";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
import { PureComponent } from "react";
|
|
5
|
-
//#region src/with-data.tsx
|
|
6
|
-
var makeInitialState = (sources) => mapValues(sources, () => ({
|
|
7
|
-
fetchState: ":fetch-state/start",
|
|
8
|
-
fetchValue: null,
|
|
9
|
-
fetchError: null
|
|
10
|
-
}));
|
|
11
|
-
function provideData({ sources }) {
|
|
12
|
-
return (Component) => class DataProvider extends PureComponent {
|
|
13
|
-
state = makeInitialState(sources);
|
|
14
|
-
_prefetch = async (key, fetch) => {
|
|
15
|
-
try {
|
|
16
|
-
const fetchValue = await fetch();
|
|
17
|
-
this.setSourceState(key, {
|
|
18
|
-
fetchState: ":fetch-state/success",
|
|
19
|
-
fetchValue,
|
|
20
|
-
fetchError: null
|
|
21
|
-
});
|
|
22
|
-
} catch (fetchError) {
|
|
23
|
-
this.setSourceState(key, {
|
|
24
|
-
fetchState: ":fetch-state/error",
|
|
25
|
-
fetchValue: null,
|
|
26
|
-
fetchError: asError(fetchError)
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
setSourceState(key, value) {
|
|
31
|
-
this.setStateIfMounted((state) => ({
|
|
32
|
-
...state,
|
|
33
|
-
[key]: value
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
36
|
-
componentDidMount() {
|
|
37
|
-
Object.keys(sources).forEach((key) => this._prefetch(key, sources[key]));
|
|
38
|
-
}
|
|
39
|
-
setStateIfMounted(updater) {
|
|
40
|
-
return this.setState(updater);
|
|
41
|
-
}
|
|
42
|
-
componentWillUnmount() {
|
|
43
|
-
this.setStateIfMounted = noop;
|
|
44
|
-
}
|
|
45
|
-
render() {
|
|
46
|
-
return /* @__PURE__ */ jsx(Component, {
|
|
47
|
-
...this.props,
|
|
48
|
-
...this.state
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
var DefaultDependenciesLoader = () => /* @__PURE__ */ jsx("div", {});
|
|
54
|
-
//#endregion
|
|
55
|
-
export { DefaultDependenciesLoader, provideData };
|