@swan-io/lake 15.3.1 → 15.5.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/package.json +5 -5
- package/src/components/Accordion.d.ts +1 -1
- package/src/components/AppOpeningAnimation.d.ts +1 -1
- package/src/components/AutoWidthImage.d.ts +1 -1
- package/src/components/AutocompleteSearchInput.d.ts +1 -1
- package/src/components/AutocompleteSearchInput.js +2 -2
- package/src/components/Avatar.js +3 -6
- package/src/components/BorderedIcon.d.ts +1 -1
- package/src/components/BottomPanel.d.ts +1 -1
- package/src/components/Box.d.ts +1 -1
- package/src/components/Breadcrumbs.d.ts +2 -2
- package/src/components/Breadcrumbs.js +4 -6
- package/src/components/BulletList.d.ts +10 -0
- package/src/components/BulletList.js +12 -0
- package/src/components/Cells.d.ts +6 -6
- package/src/components/Cells.js +1 -1
- package/src/components/ContextMenu.d.ts +2 -2
- package/src/components/ContextMenu.js +1 -1
- package/src/components/EmptyView.d.ts +1 -1
- package/src/components/EmptyView.js +1 -1
- package/src/components/Fill.d.ts +1 -1
- package/src/components/FlatList.d.ts +1 -1
- package/src/components/FlatList.js +3 -3
- package/src/components/FlowPresentation.d.ts +1 -1
- package/src/components/FocusTrap.d.ts +1 -1
- package/src/components/Form.d.ts +120 -123
- package/src/components/FullViewportLayer.d.ts +1 -1
- package/src/components/Grid.d.ts +1 -1
- package/src/components/Icon.js +1 -1
- package/src/components/InputError.d.ts +1 -1
- package/src/components/LakeAlert.d.ts +1 -1
- package/src/components/LakeAlert.js +6 -5
- package/src/components/LakeButton.d.ts +2 -2
- package/src/components/LakeButton.js +1 -1
- package/src/components/LakeCheckbox.d.ts +2 -2
- package/src/components/LakeCheckbox.js +2 -2
- package/src/components/LakeCombobox.d.ts +1 -1
- package/src/components/LakeCopyButton.d.ts +1 -1
- package/src/components/LakeDownloadButton.d.ts +1 -1
- package/src/components/LakeHeading.d.ts +1 -1
- package/src/components/LakeLabel.d.ts +1 -1
- package/src/components/LakeLabel.js +2 -2
- package/src/components/LakeRadio.d.ts +1 -1
- package/src/components/LakeScrollView.d.ts +1 -1
- package/src/components/LakeSelect.d.ts +1 -1
- package/src/components/LakeSelect.js +8 -10
- package/src/components/LakeSlider.d.ts +1 -1
- package/src/components/LakeStepper.d.ts +3 -3
- package/src/components/LakeStepper.js +3 -3
- package/src/components/LakeTagInput.d.ts +1 -1
- package/src/components/LakeText.d.ts +1 -1
- package/src/components/LakeTextInput.d.ts +1 -1
- package/src/components/LakeTextInput.js +1 -1
- package/src/components/LakeTooltip.d.ts +4 -3
- package/src/components/LakeTooltip.js +4 -4
- package/src/components/Link.d.ts +1 -1
- package/src/components/ListRightPanel.d.ts +2 -2
- package/src/components/LoadingView.d.ts +1 -1
- package/src/components/MultiSelect.d.ts +1 -1
- package/src/components/MultiSelect.js +2 -2
- package/src/components/PlainListView.d.ts +3 -9
- package/src/components/PlainListView.js +1 -1
- package/src/components/PopoverContent.d.ts +1 -1
- package/src/components/Pressable.js +3 -3
- package/src/components/ProgressTracker.d.ts +22 -0
- package/src/components/ProgressTracker.js +71 -0
- package/src/components/ProjectEnvTag.d.ts +1 -1
- package/src/components/QuickActions.d.ts +1 -1
- package/src/components/QuickActions.js +6 -9
- package/src/components/RadioGroup.d.ts +1 -1
- package/src/components/RadioGroup.js +1 -1
- package/src/components/ReadOnlyFieldList.d.ts +1 -1
- package/src/components/ReadOnlyFieldList.js +1 -1
- package/src/components/ResponsiveContainer.d.ts +1 -1
- package/src/components/RightPanel.d.ts +1 -1
- package/src/components/RightPanel.js +1 -1
- package/src/components/ScrollView.d.ts +1 -1
- package/src/components/SectionList.d.ts +1 -1
- package/src/components/SectionList.js +3 -3
- package/src/components/SegmentedControl.d.ts +1 -1
- package/src/components/SegmentedControl.js +1 -1
- package/src/components/Separator.d.ts +1 -1
- package/src/components/SidebarNavigationTracker.d.ts +2 -2
- package/src/components/SidebarNavigationTracker.js +2 -1
- package/src/components/SmsOpeningAnimation.d.ts +1 -1
- package/src/components/SortBottomPanel.d.ts +1 -1
- package/src/components/Space.d.ts +1 -1
- package/src/components/Stack.d.ts +1 -1
- package/src/components/StepDots.d.ts +1 -1
- package/src/components/Suspendable.d.ts +1 -1
- package/src/components/Suspendable.js +1 -1
- package/src/components/Svg.d.ts +10 -10
- package/src/components/Svg.js +1 -1
- package/src/components/SwanLogo.d.ts +1 -1
- package/src/components/Switch.d.ts +2 -1
- package/src/components/Switch.js +2 -2
- package/src/components/TabView.d.ts +1 -1
- package/src/components/TabView.js +4 -4
- package/src/components/Tag.d.ts +1 -1
- package/src/components/Tag.js +1 -1
- package/src/components/Tick.d.ts +1 -1
- package/src/components/Tile.d.ts +13 -6
- package/src/components/Tile.js +32 -6
- package/src/components/TilePlaceholder.d.ts +4 -2
- package/src/components/TilePlaceholder.js +3 -3
- package/src/components/TimePicker.d.ts +2 -2
- package/src/components/Toggle.d.ts +1 -1
- package/src/components/Toggle.js +1 -1
- package/src/components/TransitionGroupView.d.ts +1 -1
- package/src/components/TransitionGroupView.js +1 -1
- package/src/components/TransitionView.d.ts +1 -1
- package/src/components/VirtualizedList.d.ts +2 -2
- package/src/components/VirtualizedList.js +2 -2
- package/src/components/WithCurrentColor.d.ts +2 -2
- package/src/components/WithPartnerAccentColor.d.ts +1 -1
- package/src/hooks/useContextualLayer.d.ts +1 -0
- package/src/hooks/useContextualLayer.js +16 -8
- package/src/hooks/useUpdateEffect.js +1 -2
- package/src/utils/array.js +1 -1
- package/src/utils/highlights.js +2 -1
- package/src/utils/string.js +1 -1
- package/src/utils/svg.js +5 -5
|
@@ -4,5 +4,5 @@ type Props = {
|
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
scoped?: boolean;
|
|
6
6
|
};
|
|
7
|
-
export declare const WithPartnerAccentColor: ({ color, scoped, children }: Props) => import("react
|
|
7
|
+
export declare const WithPartnerAccentColor: ({ color, scoped, children }: Props) => import("react").JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -33,6 +33,7 @@ export type ContextualLayerPosition = {
|
|
|
33
33
|
};
|
|
34
34
|
type ContextualLayerConfig = {
|
|
35
35
|
referenceRef: RefObject<View | Text | null>;
|
|
36
|
+
contentRef: RefObject<View | Text | null>;
|
|
36
37
|
position: Option<ContextualLayerPosition>;
|
|
37
38
|
};
|
|
38
39
|
export declare const useContextualLayer: ({ placement, verticalPlacement, visible, matchReferenceWidth, matchReferenceMinWidth, referenceRef: externalReferenceRef, }: Config) => ContextualLayerConfig;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Option } from "@swan-io/boxed";
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
3
|
import { match } from "ts-pattern";
|
|
4
|
-
const MAX_OFFSET_FOR_CENTER_PLACEMENT = 100;
|
|
5
4
|
const HORIZONTAL_SAFETY_MARGIN = 16;
|
|
6
|
-
export const useContextualLayer = ({ placement, verticalPlacement, visible, matchReferenceWidth = false, matchReferenceMinWidth = false, referenceRef: externalReferenceRef, }) => {
|
|
5
|
+
export const useContextualLayer = ({ placement = "left", verticalPlacement, visible, matchReferenceWidth = false, matchReferenceMinWidth = false, referenceRef: externalReferenceRef, }) => {
|
|
7
6
|
const referenceRef = useRef(null);
|
|
7
|
+
const contentRef = useRef(null);
|
|
8
8
|
const usedRef = externalReferenceRef !== null && externalReferenceRef !== void 0 ? externalReferenceRef : referenceRef;
|
|
9
9
|
const [position, setPosition] = useState(Option.None());
|
|
10
10
|
const getPosition = useCallback(() => {
|
|
@@ -21,12 +21,19 @@ export const useContextualLayer = ({ placement, verticalPlacement, visible, matc
|
|
|
21
21
|
const availableSpaceAfter = viewportWidth - rect.right;
|
|
22
22
|
const height = rect.bottom - rect.top;
|
|
23
23
|
const width = rect.right - rect.left;
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
const contentElement = contentRef.current;
|
|
25
|
+
// if contentRef isn't used in the component, we don't infer the placement depending on content size
|
|
26
|
+
const contentRect = contentElement != null ? contentElement.getBoundingClientRect() : { width: 0, height: 0 };
|
|
27
|
+
const contentWidth = contentRect.width;
|
|
28
|
+
const contentMidWidth = contentWidth / 2;
|
|
29
|
+
const isCenteredEnough = availableSpaceBefore > contentMidWidth && availableSpaceAfter > contentMidWidth;
|
|
30
|
+
const bestPlacement = availableSpaceBefore > availableSpaceAfter ? "right" : "left";
|
|
31
|
+
const inferedPlacement = match(placement)
|
|
32
|
+
.returnType()
|
|
33
|
+
.with("center", () => (isCenteredEnough ? "center" : bestPlacement))
|
|
34
|
+
.with("left", () => (availableSpaceBefore > contentWidth ? "left" : bestPlacement))
|
|
35
|
+
.with("right", () => (availableSpaceAfter > contentWidth ? "right" : bestPlacement))
|
|
36
|
+
.exhaustive();
|
|
30
37
|
const openAbove = verticalPlacement === "above"
|
|
31
38
|
? true
|
|
32
39
|
: verticalPlacement === "below"
|
|
@@ -93,6 +100,7 @@ export const useContextualLayer = ({ placement, verticalPlacement, visible, matc
|
|
|
93
100
|
}, [visible, getPosition]);
|
|
94
101
|
return {
|
|
95
102
|
referenceRef: usedRef,
|
|
103
|
+
contentRef,
|
|
96
104
|
position,
|
|
97
105
|
};
|
|
98
106
|
};
|
|
@@ -2,11 +2,10 @@ import { useEffect } from "react";
|
|
|
2
2
|
import { useFirstMountState } from "./useFirstMountState";
|
|
3
3
|
export const useUpdateEffect = (effect, deps) => {
|
|
4
4
|
const isFirstMount = useFirstMountState();
|
|
5
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies(effect):
|
|
6
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies(isFirstMount):
|
|
7
5
|
useEffect(() => {
|
|
8
6
|
if (!isFirstMount) {
|
|
9
7
|
return effect();
|
|
10
8
|
}
|
|
9
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: rerun effect only when deps change
|
|
11
10
|
}, deps);
|
|
12
11
|
};
|
package/src/utils/array.js
CHANGED
package/src/utils/highlights.js
CHANGED
package/src/utils/string.js
CHANGED
|
@@ -233,4 +233,4 @@ export const upperCase = (value) => value.toUpperCase();
|
|
|
233
233
|
export const capitalize = (value) => `${value.charAt(0).toUpperCase()}${value.slice(1)}`;
|
|
234
234
|
export const uncapitalize = (value) => `${value.charAt(0).toLowerCase()}${value.slice(1)}`;
|
|
235
235
|
export const optionFromString = (value) => value !== "" ? Option.Some(value) : Option.None();
|
|
236
|
-
export const getFlagGlyphName = (flag) => { var _a, _b
|
|
236
|
+
export const getFlagGlyphName = (flag) => { var _a, _b; var _c, _d; return `${(_c = (_a = flag.codePointAt(0)) === null || _a === void 0 ? void 0 : _a.toString(16)) !== null && _c !== void 0 ? _c : ""}-${(_d = (_b = flag.codePointAt(2)) === null || _b === void 0 ? void 0 : _b.toString(16)) !== null && _d !== void 0 ? _d : ""}`; };
|
package/src/utils/svg.js
CHANGED
|
@@ -11,16 +11,16 @@ export const getSvgSize = (svg) => {
|
|
|
11
11
|
// first we try to get width and height from "width" and "height" attributes
|
|
12
12
|
const widthAttr = svg.getAttribute("width");
|
|
13
13
|
const heightAttr = svg.getAttribute("height");
|
|
14
|
-
const width = isNotNullish(widthAttr) ? Number.parseInt(widthAttr) : Number.NaN;
|
|
15
|
-
const height = isNotNullish(heightAttr) ? Number.parseInt(heightAttr) : Number.NaN;
|
|
14
|
+
const width = isNotNullish(widthAttr) ? Number.parseInt(widthAttr, 10) : Number.NaN;
|
|
15
|
+
const height = isNotNullish(heightAttr) ? Number.parseInt(heightAttr, 10) : Number.NaN;
|
|
16
16
|
if (!Number.isNaN(width) || !Number.isNaN(height)) {
|
|
17
17
|
return Result.Ok({ width, height });
|
|
18
18
|
}
|
|
19
19
|
// if height and width aren't provided, we get values from viewBox attribute
|
|
20
20
|
const viewBox = svg.getAttribute("viewBox");
|
|
21
21
|
const [, , boxWidthAttr, boxHeightAttr] = (_a = viewBox === null || viewBox === void 0 ? void 0 : viewBox.split(" ")) !== null && _a !== void 0 ? _a : [];
|
|
22
|
-
const boxWidth = isNotNullish(boxWidthAttr) ? Number.parseInt(boxWidthAttr) : Number.NaN;
|
|
23
|
-
const boxHeight = isNotNullish(boxHeightAttr) ? Number.parseInt(boxHeightAttr) : Number.NaN;
|
|
22
|
+
const boxWidth = isNotNullish(boxWidthAttr) ? Number.parseInt(boxWidthAttr, 10) : Number.NaN;
|
|
23
|
+
const boxHeight = isNotNullish(boxHeightAttr) ? Number.parseInt(boxHeightAttr, 10) : Number.NaN;
|
|
24
24
|
if (Number.isNaN(boxWidth) || Number.isNaN(boxHeight)) {
|
|
25
25
|
return Result.Error("VIEWBOX_MISSING");
|
|
26
26
|
}
|
|
@@ -68,7 +68,7 @@ const getMatrixColor = (color) => {
|
|
|
68
68
|
const green = colorIntensity;
|
|
69
69
|
const blue = colorIntensity;
|
|
70
70
|
const alpha = 1;
|
|
71
|
-
//
|
|
71
|
+
// biome-ignore format: keep matrix format for readability
|
|
72
72
|
const matrix = [
|
|
73
73
|
red, red, red, red, red, // R
|
|
74
74
|
green, green, green, green, green, // G
|