alouette 20.2.0 → 20.3.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/dist/definitions/index.d.ts +4 -0
- package/dist/definitions/index.d.ts.map +1 -1
- package/dist/definitions/ui/containers/AlertDialog.d.ts +78 -0
- package/dist/definitions/ui/containers/AlertDialog.d.ts.map +1 -0
- package/dist/definitions/ui/containers/AlertDialog.stories.d.ts +33 -0
- package/dist/definitions/ui/containers/AlertDialog.stories.d.ts.map +1 -0
- package/dist/definitions/ui/containers/Modal.d.ts +66 -0
- package/dist/definitions/ui/containers/Modal.d.ts.map +1 -0
- package/dist/definitions/ui/containers/Modal.stories.d.ts +31 -0
- package/dist/definitions/ui/containers/Modal.stories.d.ts.map +1 -0
- package/dist/index-browser.es.js +237 -17
- package/dist/index-browser.es.js.map +1 -1
- package/dist/index-node22.cjs +242 -16
- package/dist/index-node22.cjs.map +1 -1
- package/dist/index-node22.mjs +240 -20
- package/dist/index-node22.mjs.map +1 -1
- package/dist/index-react-native.cjs.js +242 -16
- package/dist/index-react-native.cjs.js.map +1 -1
- package/dist/index-react-native.es.js +240 -20
- package/dist/index-react-native.es.js.map +1 -1
- package/package.json +1 -1
- package/src/config/defaultColorScales.ts +1 -1
- package/src/index.ts +13 -0
- package/src/ui/containers/AlertDialog.stories.tsx +425 -0
- package/src/ui/containers/AlertDialog.tsx +211 -0
- package/src/ui/containers/Modal.stories.tsx +231 -0
- package/src/ui/containers/Modal.tsx +197 -0
package/dist/index-node22.mjs
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
2
2
|
import { VariableContextProvider, styled as styled$1 } from 'nativewind';
|
|
3
|
-
import { createContext, useContext, forwardRef, Children, cloneElement, Fragment, useRef, useState, useEffect, isValidElement, useCallback } from 'react';
|
|
4
|
-
import { useColorScheme, View as View$1, Text as Text$1, ScrollView as ScrollView$1, FlatList as FlatList$1, SectionList as SectionList$1, Pressable, Platform,
|
|
3
|
+
import { createContext, useContext, forwardRef, Children, cloneElement, Fragment, useRef, useState, useEffect, isValidElement, useId, useCallback } from 'react';
|
|
4
|
+
import { useColorScheme, View as View$1, Text as Text$1, ScrollView as ScrollView$1, FlatList as FlatList$1, SectionList as SectionList$1, Pressable, Platform, useWindowDimensions, Modal as Modal$1, TextInput, Switch as Switch$1, Linking } from 'react-native';
|
|
5
5
|
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
6
6
|
export { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
7
7
|
import { extendTailwindMerge, twMerge as twMerge$1 } from 'tailwind-merge';
|
|
8
8
|
import { tv } from 'tailwind-variants';
|
|
9
|
+
import { XRegularIcon } from 'alouette-icons/phosphor-icons/XRegularIcon';
|
|
9
10
|
import { CheckRegularIcon } from 'alouette-icons/phosphor-icons/CheckRegularIcon';
|
|
10
|
-
import { CaretDownRegularIcon } from 'alouette-icons/phosphor-icons/CaretDownRegularIcon';
|
|
11
11
|
import { InfoRegularIcon } from 'alouette-icons/phosphor-icons/InfoRegularIcon';
|
|
12
|
+
import { QuestionRegularIcon } from 'alouette-icons/phosphor-icons/QuestionRegularIcon';
|
|
12
13
|
import { WarningRegularIcon } from 'alouette-icons/phosphor-icons/WarningRegularIcon';
|
|
13
|
-
import {
|
|
14
|
+
import { CaretDownRegularIcon } from 'alouette-icons/phosphor-icons/CaretDownRegularIcon';
|
|
14
15
|
import { CaretRightRegularIcon } from 'alouette-icons/phosphor-icons/CaretRightRegularIcon';
|
|
15
16
|
import * as WebBrowser from 'expo-web-browser';
|
|
16
17
|
import { WebBrowserPresentationStyle } from 'expo-web-browser';
|
|
@@ -1246,20 +1247,6 @@ const animationDurationsMs = {
|
|
|
1246
1247
|
"collapse": 800
|
|
1247
1248
|
};
|
|
1248
1249
|
|
|
1249
|
-
function Icon({
|
|
1250
|
-
icon,
|
|
1251
|
-
size = 20,
|
|
1252
|
-
className = "text-sharp"
|
|
1253
|
-
}) {
|
|
1254
|
-
const token = className.split(/\s+/).find((part) => part.startsWith("text-"))?.slice("text-".length);
|
|
1255
|
-
const color = useThemeToken(`--color-${token ?? "sharp"}`);
|
|
1256
|
-
return cloneElement(icon, {
|
|
1257
|
-
color,
|
|
1258
|
-
width: size,
|
|
1259
|
-
height: size
|
|
1260
|
-
});
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
1250
|
const pressableBoxVariants = tv(
|
|
1264
1251
|
{
|
|
1265
1252
|
extend: interactiveBoxVariants,
|
|
@@ -1391,6 +1378,20 @@ const PressableBox = forwardRef(
|
|
|
1391
1378
|
}
|
|
1392
1379
|
);
|
|
1393
1380
|
|
|
1381
|
+
function Icon({
|
|
1382
|
+
icon,
|
|
1383
|
+
size = 20,
|
|
1384
|
+
className = "text-sharp"
|
|
1385
|
+
}) {
|
|
1386
|
+
const token = className.split(/\s+/).find((part) => part.startsWith("text-"))?.slice("text-".length);
|
|
1387
|
+
const color = useThemeToken(`--color-${token ?? "sharp"}`);
|
|
1388
|
+
return cloneElement(icon, {
|
|
1389
|
+
color,
|
|
1390
|
+
width: size,
|
|
1391
|
+
height: size
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1394
1395
|
const buttonHeight = {
|
|
1395
1396
|
sm: 38,
|
|
1396
1397
|
md: 44
|
|
@@ -1602,6 +1603,225 @@ function IconButton({
|
|
|
1602
1603
|
);
|
|
1603
1604
|
}
|
|
1604
1605
|
|
|
1606
|
+
const panelVariants = tv(
|
|
1607
|
+
{
|
|
1608
|
+
// w-full so the panel shrinks on small screens (the backdrop padding keeps a
|
|
1609
|
+
// margin); max-w caps it on wide viewports.
|
|
1610
|
+
base: "w-full",
|
|
1611
|
+
variants: {
|
|
1612
|
+
size: {
|
|
1613
|
+
sm: "max-w-[360px]",
|
|
1614
|
+
md: "max-w-[520px]",
|
|
1615
|
+
lg: "max-w-[720px]"
|
|
1616
|
+
}
|
|
1617
|
+
},
|
|
1618
|
+
defaultVariants: { size: "md" }
|
|
1619
|
+
},
|
|
1620
|
+
{ twMerge: false }
|
|
1621
|
+
);
|
|
1622
|
+
const titleReserveVariants = tv(
|
|
1623
|
+
{
|
|
1624
|
+
variants: {
|
|
1625
|
+
size: {
|
|
1626
|
+
sm: "pr-xxl",
|
|
1627
|
+
md: "pr-xl",
|
|
1628
|
+
lg: "pr-xl"
|
|
1629
|
+
}
|
|
1630
|
+
},
|
|
1631
|
+
defaultVariants: { size: "md" }
|
|
1632
|
+
},
|
|
1633
|
+
{ twMerge: false }
|
|
1634
|
+
);
|
|
1635
|
+
function Modal({
|
|
1636
|
+
visible,
|
|
1637
|
+
onClose,
|
|
1638
|
+
children,
|
|
1639
|
+
icon,
|
|
1640
|
+
footer,
|
|
1641
|
+
accent,
|
|
1642
|
+
size = "md",
|
|
1643
|
+
title,
|
|
1644
|
+
hideCloseButton = false,
|
|
1645
|
+
closeButtonAriaLabel = "Close",
|
|
1646
|
+
role = "dialog",
|
|
1647
|
+
"aria-describedby": ariaDescribedby,
|
|
1648
|
+
testID,
|
|
1649
|
+
"aria-label": ariaLabel
|
|
1650
|
+
}) {
|
|
1651
|
+
const { height: windowHeight } = useWindowDimensions();
|
|
1652
|
+
const titleId = useId();
|
|
1653
|
+
return /* @__PURE__ */ jsx(AccentScope, { accent, children: /* @__PURE__ */ jsx(
|
|
1654
|
+
Modal$1,
|
|
1655
|
+
{
|
|
1656
|
+
transparent: true,
|
|
1657
|
+
visible,
|
|
1658
|
+
animationType: "fade",
|
|
1659
|
+
onRequestClose: onClose,
|
|
1660
|
+
children: /* @__PURE__ */ jsxs(View, { className: "flex-1 flex-center p-l", children: [
|
|
1661
|
+
/* @__PURE__ */ jsx(
|
|
1662
|
+
Pressable,
|
|
1663
|
+
{
|
|
1664
|
+
"aria-hidden": true,
|
|
1665
|
+
focusable: false,
|
|
1666
|
+
className: "absolute inset-0 bg-translucent",
|
|
1667
|
+
onPress: onClose
|
|
1668
|
+
}
|
|
1669
|
+
),
|
|
1670
|
+
/* @__PURE__ */ jsx(
|
|
1671
|
+
View,
|
|
1672
|
+
{
|
|
1673
|
+
"aria-modal": true,
|
|
1674
|
+
role,
|
|
1675
|
+
"aria-label": title === void 0 ? ariaLabel : void 0,
|
|
1676
|
+
"aria-labelledby": title === void 0 ? void 0 : titleId,
|
|
1677
|
+
"aria-describedby": ariaDescribedby,
|
|
1678
|
+
testID,
|
|
1679
|
+
className: `relative ${panelVariants({ size })}`,
|
|
1680
|
+
children: /* @__PURE__ */ jsxs(
|
|
1681
|
+
Surface,
|
|
1682
|
+
{
|
|
1683
|
+
variant: "highlight",
|
|
1684
|
+
size,
|
|
1685
|
+
shadow: "l",
|
|
1686
|
+
className: "relative gap-m",
|
|
1687
|
+
children: [
|
|
1688
|
+
title === void 0 && icon === void 0 ? null : /* @__PURE__ */ jsxs(
|
|
1689
|
+
HStack,
|
|
1690
|
+
{
|
|
1691
|
+
className: `items-center gap-xs ${hideCloseButton ? "" : titleReserveVariants({ size })}`,
|
|
1692
|
+
children: [
|
|
1693
|
+
icon === void 0 ? null : /* @__PURE__ */ jsx(Icon, { icon, size: 24, className: "text-accent" }),
|
|
1694
|
+
title === void 0 ? null : /* @__PURE__ */ jsx(
|
|
1695
|
+
Text,
|
|
1696
|
+
{
|
|
1697
|
+
nativeID: titleId,
|
|
1698
|
+
className: "shrink font-heading-bold text-xl leading-tight text-sharp",
|
|
1699
|
+
children: title
|
|
1700
|
+
}
|
|
1701
|
+
)
|
|
1702
|
+
]
|
|
1703
|
+
}
|
|
1704
|
+
),
|
|
1705
|
+
hideCloseButton ? null : /* @__PURE__ */ jsx(
|
|
1706
|
+
IconButton,
|
|
1707
|
+
{
|
|
1708
|
+
icon: /* @__PURE__ */ jsx(XRegularIcon, {}),
|
|
1709
|
+
variant: "ghost",
|
|
1710
|
+
size: size === "lg" ? "md" : size,
|
|
1711
|
+
"aria-label": closeButtonAriaLabel,
|
|
1712
|
+
className: "absolute right-sm top-sm",
|
|
1713
|
+
onPress: onClose
|
|
1714
|
+
}
|
|
1715
|
+
),
|
|
1716
|
+
/* @__PURE__ */ jsx(ScrollView, { style: { maxHeight: windowHeight * 0.7 }, children: /* @__PURE__ */ jsx(VStack, { className: "gap-m", children }) }),
|
|
1717
|
+
footer === void 0 ? null : /* @__PURE__ */ jsx(HStack, { className: "items-center justify-end gap-m", children: footer })
|
|
1718
|
+
]
|
|
1719
|
+
}
|
|
1720
|
+
)
|
|
1721
|
+
}
|
|
1722
|
+
)
|
|
1723
|
+
] })
|
|
1724
|
+
}
|
|
1725
|
+
) });
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
function resolveVariant(props, accent) {
|
|
1729
|
+
switch (props.variant) {
|
|
1730
|
+
case "alert": {
|
|
1731
|
+
const { onClose, closeText } = props;
|
|
1732
|
+
return {
|
|
1733
|
+
onDismiss: onClose,
|
|
1734
|
+
footer: /* @__PURE__ */ jsx(Button, { accent, text: closeText ?? "OK", onPress: onClose })
|
|
1735
|
+
};
|
|
1736
|
+
}
|
|
1737
|
+
case "required": {
|
|
1738
|
+
const { onConfirm, confirmText, confirmDisabled } = props;
|
|
1739
|
+
return {
|
|
1740
|
+
// Non-dismissible: only the explicit action closes it.
|
|
1741
|
+
onDismiss: () => void 0,
|
|
1742
|
+
footer: /* @__PURE__ */ jsx(
|
|
1743
|
+
Button,
|
|
1744
|
+
{
|
|
1745
|
+
accent,
|
|
1746
|
+
text: confirmText ?? "OK",
|
|
1747
|
+
disabled: confirmDisabled,
|
|
1748
|
+
onPress: onConfirm
|
|
1749
|
+
}
|
|
1750
|
+
)
|
|
1751
|
+
};
|
|
1752
|
+
}
|
|
1753
|
+
case "confirm":
|
|
1754
|
+
case void 0:
|
|
1755
|
+
default: {
|
|
1756
|
+
const { onConfirm, onCancel, confirmText, cancelText, confirmDisabled } = props;
|
|
1757
|
+
return {
|
|
1758
|
+
onDismiss: onCancel,
|
|
1759
|
+
footer: /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1760
|
+
/* @__PURE__ */ jsx(
|
|
1761
|
+
Button,
|
|
1762
|
+
{
|
|
1763
|
+
variant: "outlined",
|
|
1764
|
+
text: cancelText ?? "Cancel",
|
|
1765
|
+
onPress: onCancel
|
|
1766
|
+
}
|
|
1767
|
+
),
|
|
1768
|
+
/* @__PURE__ */ jsx(
|
|
1769
|
+
Button,
|
|
1770
|
+
{
|
|
1771
|
+
accent,
|
|
1772
|
+
text: confirmText ?? "Confirm",
|
|
1773
|
+
disabled: confirmDisabled,
|
|
1774
|
+
onPress: onConfirm
|
|
1775
|
+
}
|
|
1776
|
+
)
|
|
1777
|
+
] })
|
|
1778
|
+
};
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
function AlertDialog(props) {
|
|
1783
|
+
const {
|
|
1784
|
+
visible,
|
|
1785
|
+
title,
|
|
1786
|
+
children,
|
|
1787
|
+
accent = "danger",
|
|
1788
|
+
icon,
|
|
1789
|
+
size = "md",
|
|
1790
|
+
testID
|
|
1791
|
+
} = props;
|
|
1792
|
+
const descriptionId = useId();
|
|
1793
|
+
const { footer, onDismiss } = resolveVariant(props, accent);
|
|
1794
|
+
return /* @__PURE__ */ jsx(
|
|
1795
|
+
Modal,
|
|
1796
|
+
{
|
|
1797
|
+
hideCloseButton: true,
|
|
1798
|
+
visible,
|
|
1799
|
+
role: "alertdialog",
|
|
1800
|
+
accent,
|
|
1801
|
+
size,
|
|
1802
|
+
title,
|
|
1803
|
+
icon,
|
|
1804
|
+
"aria-describedby": children === void 0 ? void 0 : descriptionId,
|
|
1805
|
+
testID,
|
|
1806
|
+
footer,
|
|
1807
|
+
onClose: onDismiss,
|
|
1808
|
+
children: children === void 0 ? null : /* @__PURE__ */ jsx(Text, { nativeID: descriptionId, className: "text-base text-muted", children })
|
|
1809
|
+
}
|
|
1810
|
+
);
|
|
1811
|
+
}
|
|
1812
|
+
function QuestionAlertDialog(props) {
|
|
1813
|
+
return /* @__PURE__ */ jsx(AlertDialog, { ...props, icon: /* @__PURE__ */ jsx(QuestionRegularIcon, {}) });
|
|
1814
|
+
}
|
|
1815
|
+
function WarningAlertDialog(props) {
|
|
1816
|
+
return /* @__PURE__ */ jsx(AlertDialog, { ...props, icon: /* @__PURE__ */ jsx(WarningRegularIcon, {}) });
|
|
1817
|
+
}
|
|
1818
|
+
function InfoAlertDialog(props) {
|
|
1819
|
+
return /* @__PURE__ */ jsx(AlertDialog, { ...props, icon: /* @__PURE__ */ jsx(InfoRegularIcon, {}) });
|
|
1820
|
+
}
|
|
1821
|
+
function SuccessAlertDialog(props) {
|
|
1822
|
+
return /* @__PURE__ */ jsx(AlertDialog, { ...props, icon: /* @__PURE__ */ jsx(CheckRegularIcon, {}) });
|
|
1823
|
+
}
|
|
1824
|
+
|
|
1605
1825
|
const inputVariants = tv(
|
|
1606
1826
|
{
|
|
1607
1827
|
base: [
|
|
@@ -1916,7 +2136,7 @@ function SelectInner({
|
|
|
1916
2136
|
}
|
|
1917
2137
|
),
|
|
1918
2138
|
/* @__PURE__ */ jsx(
|
|
1919
|
-
Modal,
|
|
2139
|
+
Modal$1,
|
|
1920
2140
|
{
|
|
1921
2141
|
transparent: true,
|
|
1922
2142
|
visible: open,
|
|
@@ -2316,5 +2536,5 @@ function ExternalLink({
|
|
|
2316
2536
|
return /* @__PURE__ */ jsx(C, { ...props, onPress: handlePress });
|
|
2317
2537
|
}
|
|
2318
2538
|
|
|
2319
|
-
export { AccentScope, AlouetteDecorator, AlouetteProvider, Badge, Box, BreakpointNameEnum, Breakpoints, Button, ConfirmationMessage, ConnectionState, ExternalLink, ExternalLinkButton, FlatList, GradientBackground, GradientScrollView, HStack, Icon, IconButton, InfoMessage, InputText, InteractiveBox, InternalLinkButton, Message, Paragraph, PresenceList, PresenceOne, PressableBox, PressableListItem, SafeAreaBox, ScopedTheme, ScrollView, SectionList, Select, Separator, Stack, Story, StoryContainer, StoryDecorator, StoryGrid, StoryTitle, Surface, Switch, SwitchBreakpointsUsingDisplayNone, SwitchBreakpointsUsingNull, Text, TextArea, VStack, View, WarningMessage, animationDurationsMs, styled, themeVariables, useCurrentBreakpointName, useCurrentBreakpointNameFiltered, useCurrentMode, useCurrentTheme, useThemeToken };
|
|
2539
|
+
export { AccentScope, AlertDialog, AlouetteDecorator, AlouetteProvider, Badge, Box, BreakpointNameEnum, Breakpoints, Button, ConfirmationMessage, ConnectionState, ExternalLink, ExternalLinkButton, FlatList, GradientBackground, GradientScrollView, HStack, Icon, IconButton, InfoAlertDialog, InfoMessage, InputText, InteractiveBox, InternalLinkButton, Message, Modal, Paragraph, PresenceList, PresenceOne, PressableBox, PressableListItem, QuestionAlertDialog, SafeAreaBox, ScopedTheme, ScrollView, SectionList, Select, Separator, Stack, Story, StoryContainer, StoryDecorator, StoryGrid, StoryTitle, SuccessAlertDialog, Surface, Switch, SwitchBreakpointsUsingDisplayNone, SwitchBreakpointsUsingNull, Text, TextArea, VStack, View, WarningAlertDialog, WarningMessage, animationDurationsMs, styled, themeVariables, useCurrentBreakpointName, useCurrentBreakpointNameFiltered, useCurrentMode, useCurrentTheme, useThemeToken };
|
|
2320
2540
|
//# sourceMappingURL=index-node22.mjs.map
|