@swan-io/lake 15.5.2 → 15.5.3
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 +1 -1
- package/src/components/Accordion.js +2 -2
- package/src/components/ContextMenu.js +2 -2
- package/src/components/LakeSelect.js +1 -2
- package/src/components/MultiSelect.js +1 -2
- package/src/components/Tile.js +2 -2
- package/src/hooks/useDisclosure.d.ts +0 -5
- package/src/hooks/useDisclosure.js +0 -12
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useId } from "react";
|
|
3
3
|
import { Pressable, StyleSheet, View } from "react-native";
|
|
4
4
|
import { backgroundColor, colors, spacings } from "../constants/design";
|
|
5
|
-
import {
|
|
5
|
+
import { useBoolean } from "../hooks/useBoolean";
|
|
6
6
|
import { Icon } from "./Icon";
|
|
7
7
|
import { LakeText } from "./LakeText";
|
|
8
8
|
import { Space } from "./Space";
|
|
@@ -40,6 +40,6 @@ const styles = StyleSheet.create({
|
|
|
40
40
|
});
|
|
41
41
|
export const Accordion = ({ children, trigger, style, contentContainerStyle }) => {
|
|
42
42
|
const id = useId();
|
|
43
|
-
const [isOpen, { toggle }] =
|
|
43
|
+
const [isOpen, { toggle }] = useBoolean(false);
|
|
44
44
|
return (_jsxs(View, { children: [_jsxs(Pressable, { "aria-controls": id, role: "button", "aria-expanded": isOpen, onPress: toggle, style: [styles.trigger, style], children: [_jsx(Icon, { name: "chevron-right-filled", size: 12, color: colors.gray[500], style: [styles.arrow, isOpen && styles.arrowOpen] }), _jsx(Space, { width: 20 }), typeof trigger === "string" ? (_jsx(LakeText, { variant: "smallMedium", color: colors.gray[900], children: trigger })) : (trigger)] }), _jsx(View, { "aria-labelledby": id, "aria-hidden": !isOpen, role: "region", style: [styles.contentContainer, isOpen && styles.contentContainerDisplayed], children: _jsx(View, { style: styles.contentInner, children: _jsx(View, { style: [styles.content, contentContainerStyle], children: children }) }) })] }));
|
|
45
45
|
};
|
|
@@ -2,7 +2,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { createContext, useContext, useRef } from "react";
|
|
3
3
|
import { StyleSheet, View } from "react-native";
|
|
4
4
|
import { colors, spacings } from "../constants/design";
|
|
5
|
-
import {
|
|
5
|
+
import { useBoolean } from "../hooks/useBoolean";
|
|
6
6
|
import { noop } from "../utils/function";
|
|
7
7
|
import { LakeButton } from "./LakeButton";
|
|
8
8
|
import { LakeText } from "./LakeText";
|
|
@@ -28,7 +28,7 @@ const styles = StyleSheet.create({
|
|
|
28
28
|
});
|
|
29
29
|
const ContextMenuContext = createContext({ close: noop });
|
|
30
30
|
export const ContextMenu = ({ children, ariaLabel, withPill = false, verticalPlacement, }) => {
|
|
31
|
-
const [isOpen, { open, close }] =
|
|
31
|
+
const [isOpen, { on: open, off: close }] = useBoolean(false);
|
|
32
32
|
const triggerRef = useRef(null);
|
|
33
33
|
return (_jsxs(ContextMenuContext.Provider, { value: { close }, children: [_jsx(LakeButton, { ref: triggerRef, mode: "tertiary", size: "small", icon: "more-horizontal-filled", color: "gray", onPress: open, ariaLabel: ariaLabel, pill: withPill }), _jsx(Popover, { referenceRef: triggerRef, visible: isOpen, onDismiss: close, verticalPlacement: verticalPlacement, children: _jsx(View, { style: styles.container, children: children }) })] }));
|
|
34
34
|
};
|
|
@@ -5,7 +5,6 @@ import { t } from "../../../shared-business/src/utils/i18n";
|
|
|
5
5
|
import { commonStyles } from "../constants/commonStyles";
|
|
6
6
|
import { backgroundColor, colors, invariantColors, radii, shadows, spacings, texts, } from "../constants/design";
|
|
7
7
|
import { useBoolean } from "../hooks/useBoolean";
|
|
8
|
-
import { useDisclosure } from "../hooks/useDisclosure";
|
|
9
8
|
import { useMergeRefs } from "../hooks/useMergeRefs";
|
|
10
9
|
import { getFocusableElements } from "../utils/a11y";
|
|
11
10
|
import { setHighlightApi } from "../utils/highlights";
|
|
@@ -163,7 +162,7 @@ export const LakeSelect = ({ ref, title, items, valueStyle, size, color = "curre
|
|
|
163
162
|
const currentlyTypedRef = useRef(undefined);
|
|
164
163
|
const listItemRefs = useRef(Array(items.length));
|
|
165
164
|
const mergedRef = useMergeRefs(inputRef, ref);
|
|
166
|
-
const [visible, {
|
|
165
|
+
const [visible, { on: open, off: close }] = useBoolean(false);
|
|
167
166
|
const hasValue = isNotNullish(value);
|
|
168
167
|
const isSmall = size === "small";
|
|
169
168
|
const itemValue = items.find(i => i.value === value);
|
|
@@ -4,7 +4,6 @@ import { useEffect, useMemo, useRef, useState } from "react";
|
|
|
4
4
|
import { Pressable, StyleSheet, Text, TextInput, View, } from "react-native";
|
|
5
5
|
import { backgroundColor, colors, radii, shadows, texts } from "../constants/design";
|
|
6
6
|
import { useBoolean } from "../hooks/useBoolean";
|
|
7
|
-
import { useDisclosure } from "../hooks/useDisclosure";
|
|
8
7
|
import { groupBy } from "../utils/array";
|
|
9
8
|
import { isNotNullish, isNotNullishOrEmpty } from "../utils/nullish";
|
|
10
9
|
import { safeSplitAround } from "../utils/string";
|
|
@@ -143,7 +142,7 @@ export const MultiSelect = ({ color = "gray", disabled = false, emptyResultText,
|
|
|
143
142
|
const shouldScrollToBottomRef = useRef(false);
|
|
144
143
|
const selectedTagListRef = useRef(null);
|
|
145
144
|
const inputRef = useRef(null);
|
|
146
|
-
const [visible, { open, close }] =
|
|
145
|
+
const [visible, { on: open, off: close }] = useBoolean(false);
|
|
147
146
|
const tint50 = colors[color][50];
|
|
148
147
|
const tint100 = colors[color][100];
|
|
149
148
|
useEffect(() => {
|
package/src/components/Tile.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { Children, cloneElement, Fragment, useCallback, useId, useState, } from "react";
|
|
3
3
|
import { Pressable, StyleSheet, Text, View, } from "react-native";
|
|
4
4
|
import { backgroundColor, colors, negativeSpacings, radii, shadows, spacings, texts, } from "../constants/design";
|
|
5
|
-
import {
|
|
5
|
+
import { useBoolean } from "../hooks/useBoolean";
|
|
6
6
|
import { isNotNullish } from "../utils/nullish";
|
|
7
7
|
import { Box } from "./Box";
|
|
8
8
|
import { Icon } from "./Icon";
|
|
@@ -99,7 +99,7 @@ const styles = StyleSheet.create({
|
|
|
99
99
|
});
|
|
100
100
|
export const Tile = ({ icon, title, description, headerEnd, footer, flexBasis, children, numberOfLines, paddingVertical = 32, paddingHorizontal = 32, hovered = false, flexGrow = 0, flexShrink = 0, disabled = false, selected, collapsible = false, defaultExpanded = true, style, }) => {
|
|
101
101
|
const contentId = useId();
|
|
102
|
-
const [expanded, { toggle }] =
|
|
102
|
+
const [expanded, { toggle }] = useBoolean(defaultExpanded);
|
|
103
103
|
const hasHeader = isNotNullish(title) || isNotNullish(headerEnd) || isNotNullish(description) || collapsible;
|
|
104
104
|
const header = (_jsxs(_Fragment, { children: [_jsxs(View, { style: styles.header, children: [_jsxs(View, { style: styles.headerTitleIcon, children: [isNotNullish(icon) && (_jsxs(_Fragment, { children: [icon, _jsx(Space, { height: 12 })] })), isNotNullish(title) && (_jsx(Text, { style: styles.title, role: "heading", "aria-level": 3, children: title }))] }), collapsible ? (_jsx(Icon, { name: "chevron-down-filled", size: 16, color: colors.gray[500], style: [styles.chevron, expanded && styles.chevronOpen] })) : isNotNullish(headerEnd) ? (_jsx(View, { children: headerEnd })) : null] }), isNotNullish(description) && (_jsxs(_Fragment, { children: [isNotNullish(title) && _jsx(Space, { height: 12 }), _jsx(View, { style: styles.descriptionContainer, children: _jsx(LakeText, { numberOfLines: numberOfLines, style: styles.description, children: description }) })] }))] }));
|
|
105
105
|
const content = (_jsxs(_Fragment, { children: [children, isNotNullish(footer) && (_jsx(View, { style: [styles.footer, { marginTop: paddingVertical, marginBottom: -paddingVertical }], children: footer }))] }));
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useMemo, useState } from "react";
|
|
2
|
-
export const useDisclosure = (initialValue) => {
|
|
3
|
-
const [value, setValue] = useState(initialValue);
|
|
4
|
-
return [
|
|
5
|
-
value,
|
|
6
|
-
useMemo(() => ({
|
|
7
|
-
open: () => setValue(true),
|
|
8
|
-
close: () => setValue(false),
|
|
9
|
-
toggle: () => setValue(prevValue => !prevValue),
|
|
10
|
-
}), []),
|
|
11
|
-
];
|
|
12
|
-
};
|