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.cjs
CHANGED
|
@@ -9,11 +9,12 @@ const reactNative = require('react-native');
|
|
|
9
9
|
const reactNativeSafeAreaContext = require('react-native-safe-area-context');
|
|
10
10
|
const tailwindMerge = require('tailwind-merge');
|
|
11
11
|
const tailwindVariants = require('tailwind-variants');
|
|
12
|
+
const XRegularIcon = require('alouette-icons/phosphor-icons/XRegularIcon');
|
|
12
13
|
const CheckRegularIcon = require('alouette-icons/phosphor-icons/CheckRegularIcon');
|
|
13
|
-
const CaretDownRegularIcon = require('alouette-icons/phosphor-icons/CaretDownRegularIcon');
|
|
14
14
|
const InfoRegularIcon = require('alouette-icons/phosphor-icons/InfoRegularIcon');
|
|
15
|
+
const QuestionRegularIcon = require('alouette-icons/phosphor-icons/QuestionRegularIcon');
|
|
15
16
|
const WarningRegularIcon = require('alouette-icons/phosphor-icons/WarningRegularIcon');
|
|
16
|
-
const
|
|
17
|
+
const CaretDownRegularIcon = require('alouette-icons/phosphor-icons/CaretDownRegularIcon');
|
|
17
18
|
const CaretRightRegularIcon = require('alouette-icons/phosphor-icons/CaretRightRegularIcon');
|
|
18
19
|
const WebBrowser = require('expo-web-browser');
|
|
19
20
|
|
|
@@ -1261,20 +1262,6 @@ const animationDurationsMs = {
|
|
|
1261
1262
|
"collapse": 800
|
|
1262
1263
|
};
|
|
1263
1264
|
|
|
1264
|
-
function Icon({
|
|
1265
|
-
icon,
|
|
1266
|
-
size = 20,
|
|
1267
|
-
className = "text-sharp"
|
|
1268
|
-
}) {
|
|
1269
|
-
const token = className.split(/\s+/).find((part) => part.startsWith("text-"))?.slice("text-".length);
|
|
1270
|
-
const color = useThemeToken(`--color-${token ?? "sharp"}`);
|
|
1271
|
-
return react.cloneElement(icon, {
|
|
1272
|
-
color,
|
|
1273
|
-
width: size,
|
|
1274
|
-
height: size
|
|
1275
|
-
});
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
1265
|
const pressableBoxVariants = tailwindVariants.tv(
|
|
1279
1266
|
{
|
|
1280
1267
|
extend: interactiveBoxVariants,
|
|
@@ -1406,6 +1393,20 @@ const PressableBox = react.forwardRef(
|
|
|
1406
1393
|
}
|
|
1407
1394
|
);
|
|
1408
1395
|
|
|
1396
|
+
function Icon({
|
|
1397
|
+
icon,
|
|
1398
|
+
size = 20,
|
|
1399
|
+
className = "text-sharp"
|
|
1400
|
+
}) {
|
|
1401
|
+
const token = className.split(/\s+/).find((part) => part.startsWith("text-"))?.slice("text-".length);
|
|
1402
|
+
const color = useThemeToken(`--color-${token ?? "sharp"}`);
|
|
1403
|
+
return react.cloneElement(icon, {
|
|
1404
|
+
color,
|
|
1405
|
+
width: size,
|
|
1406
|
+
height: size
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1409
1410
|
const buttonHeight = {
|
|
1410
1411
|
sm: 38,
|
|
1411
1412
|
md: 44
|
|
@@ -1617,6 +1618,225 @@ function IconButton({
|
|
|
1617
1618
|
);
|
|
1618
1619
|
}
|
|
1619
1620
|
|
|
1621
|
+
const panelVariants = tailwindVariants.tv(
|
|
1622
|
+
{
|
|
1623
|
+
// w-full so the panel shrinks on small screens (the backdrop padding keeps a
|
|
1624
|
+
// margin); max-w caps it on wide viewports.
|
|
1625
|
+
base: "w-full",
|
|
1626
|
+
variants: {
|
|
1627
|
+
size: {
|
|
1628
|
+
sm: "max-w-[360px]",
|
|
1629
|
+
md: "max-w-[520px]",
|
|
1630
|
+
lg: "max-w-[720px]"
|
|
1631
|
+
}
|
|
1632
|
+
},
|
|
1633
|
+
defaultVariants: { size: "md" }
|
|
1634
|
+
},
|
|
1635
|
+
{ twMerge: false }
|
|
1636
|
+
);
|
|
1637
|
+
const titleReserveVariants = tailwindVariants.tv(
|
|
1638
|
+
{
|
|
1639
|
+
variants: {
|
|
1640
|
+
size: {
|
|
1641
|
+
sm: "pr-xxl",
|
|
1642
|
+
md: "pr-xl",
|
|
1643
|
+
lg: "pr-xl"
|
|
1644
|
+
}
|
|
1645
|
+
},
|
|
1646
|
+
defaultVariants: { size: "md" }
|
|
1647
|
+
},
|
|
1648
|
+
{ twMerge: false }
|
|
1649
|
+
);
|
|
1650
|
+
function Modal({
|
|
1651
|
+
visible,
|
|
1652
|
+
onClose,
|
|
1653
|
+
children,
|
|
1654
|
+
icon,
|
|
1655
|
+
footer,
|
|
1656
|
+
accent,
|
|
1657
|
+
size = "md",
|
|
1658
|
+
title,
|
|
1659
|
+
hideCloseButton = false,
|
|
1660
|
+
closeButtonAriaLabel = "Close",
|
|
1661
|
+
role = "dialog",
|
|
1662
|
+
"aria-describedby": ariaDescribedby,
|
|
1663
|
+
testID,
|
|
1664
|
+
"aria-label": ariaLabel
|
|
1665
|
+
}) {
|
|
1666
|
+
const { height: windowHeight } = reactNative.useWindowDimensions();
|
|
1667
|
+
const titleId = react.useId();
|
|
1668
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AccentScope, { accent, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1669
|
+
reactNative.Modal,
|
|
1670
|
+
{
|
|
1671
|
+
transparent: true,
|
|
1672
|
+
visible,
|
|
1673
|
+
animationType: "fade",
|
|
1674
|
+
onRequestClose: onClose,
|
|
1675
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(View, { className: "flex-1 flex-center p-l", children: [
|
|
1676
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1677
|
+
reactNative.Pressable,
|
|
1678
|
+
{
|
|
1679
|
+
"aria-hidden": true,
|
|
1680
|
+
focusable: false,
|
|
1681
|
+
className: "absolute inset-0 bg-translucent",
|
|
1682
|
+
onPress: onClose
|
|
1683
|
+
}
|
|
1684
|
+
),
|
|
1685
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1686
|
+
View,
|
|
1687
|
+
{
|
|
1688
|
+
"aria-modal": true,
|
|
1689
|
+
role,
|
|
1690
|
+
"aria-label": title === void 0 ? ariaLabel : void 0,
|
|
1691
|
+
"aria-labelledby": title === void 0 ? void 0 : titleId,
|
|
1692
|
+
"aria-describedby": ariaDescribedby,
|
|
1693
|
+
testID,
|
|
1694
|
+
className: `relative ${panelVariants({ size })}`,
|
|
1695
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1696
|
+
Surface,
|
|
1697
|
+
{
|
|
1698
|
+
variant: "highlight",
|
|
1699
|
+
size,
|
|
1700
|
+
shadow: "l",
|
|
1701
|
+
className: "relative gap-m",
|
|
1702
|
+
children: [
|
|
1703
|
+
title === void 0 && icon === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1704
|
+
HStack,
|
|
1705
|
+
{
|
|
1706
|
+
className: `items-center gap-xs ${hideCloseButton ? "" : titleReserveVariants({ size })}`,
|
|
1707
|
+
children: [
|
|
1708
|
+
icon === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(Icon, { icon, size: 24, className: "text-accent" }),
|
|
1709
|
+
title === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1710
|
+
Text,
|
|
1711
|
+
{
|
|
1712
|
+
nativeID: titleId,
|
|
1713
|
+
className: "shrink font-heading-bold text-xl leading-tight text-sharp",
|
|
1714
|
+
children: title
|
|
1715
|
+
}
|
|
1716
|
+
)
|
|
1717
|
+
]
|
|
1718
|
+
}
|
|
1719
|
+
),
|
|
1720
|
+
hideCloseButton ? null : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1721
|
+
IconButton,
|
|
1722
|
+
{
|
|
1723
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(XRegularIcon.XRegularIcon, {}),
|
|
1724
|
+
variant: "ghost",
|
|
1725
|
+
size: size === "lg" ? "md" : size,
|
|
1726
|
+
"aria-label": closeButtonAriaLabel,
|
|
1727
|
+
className: "absolute right-sm top-sm",
|
|
1728
|
+
onPress: onClose
|
|
1729
|
+
}
|
|
1730
|
+
),
|
|
1731
|
+
/* @__PURE__ */ jsxRuntime.jsx(ScrollView, { style: { maxHeight: windowHeight * 0.7 }, children: /* @__PURE__ */ jsxRuntime.jsx(VStack, { className: "gap-m", children }) }),
|
|
1732
|
+
footer === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(HStack, { className: "items-center justify-end gap-m", children: footer })
|
|
1733
|
+
]
|
|
1734
|
+
}
|
|
1735
|
+
)
|
|
1736
|
+
}
|
|
1737
|
+
)
|
|
1738
|
+
] })
|
|
1739
|
+
}
|
|
1740
|
+
) });
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
function resolveVariant(props, accent) {
|
|
1744
|
+
switch (props.variant) {
|
|
1745
|
+
case "alert": {
|
|
1746
|
+
const { onClose, closeText } = props;
|
|
1747
|
+
return {
|
|
1748
|
+
onDismiss: onClose,
|
|
1749
|
+
footer: /* @__PURE__ */ jsxRuntime.jsx(Button, { accent, text: closeText ?? "OK", onPress: onClose })
|
|
1750
|
+
};
|
|
1751
|
+
}
|
|
1752
|
+
case "required": {
|
|
1753
|
+
const { onConfirm, confirmText, confirmDisabled } = props;
|
|
1754
|
+
return {
|
|
1755
|
+
// Non-dismissible: only the explicit action closes it.
|
|
1756
|
+
onDismiss: () => void 0,
|
|
1757
|
+
footer: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1758
|
+
Button,
|
|
1759
|
+
{
|
|
1760
|
+
accent,
|
|
1761
|
+
text: confirmText ?? "OK",
|
|
1762
|
+
disabled: confirmDisabled,
|
|
1763
|
+
onPress: onConfirm
|
|
1764
|
+
}
|
|
1765
|
+
)
|
|
1766
|
+
};
|
|
1767
|
+
}
|
|
1768
|
+
case "confirm":
|
|
1769
|
+
case void 0:
|
|
1770
|
+
default: {
|
|
1771
|
+
const { onConfirm, onCancel, confirmText, cancelText, confirmDisabled } = props;
|
|
1772
|
+
return {
|
|
1773
|
+
onDismiss: onCancel,
|
|
1774
|
+
footer: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1775
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1776
|
+
Button,
|
|
1777
|
+
{
|
|
1778
|
+
variant: "outlined",
|
|
1779
|
+
text: cancelText ?? "Cancel",
|
|
1780
|
+
onPress: onCancel
|
|
1781
|
+
}
|
|
1782
|
+
),
|
|
1783
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1784
|
+
Button,
|
|
1785
|
+
{
|
|
1786
|
+
accent,
|
|
1787
|
+
text: confirmText ?? "Confirm",
|
|
1788
|
+
disabled: confirmDisabled,
|
|
1789
|
+
onPress: onConfirm
|
|
1790
|
+
}
|
|
1791
|
+
)
|
|
1792
|
+
] })
|
|
1793
|
+
};
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
function AlertDialog(props) {
|
|
1798
|
+
const {
|
|
1799
|
+
visible,
|
|
1800
|
+
title,
|
|
1801
|
+
children,
|
|
1802
|
+
accent = "danger",
|
|
1803
|
+
icon,
|
|
1804
|
+
size = "md",
|
|
1805
|
+
testID
|
|
1806
|
+
} = props;
|
|
1807
|
+
const descriptionId = react.useId();
|
|
1808
|
+
const { footer, onDismiss } = resolveVariant(props, accent);
|
|
1809
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1810
|
+
Modal,
|
|
1811
|
+
{
|
|
1812
|
+
hideCloseButton: true,
|
|
1813
|
+
visible,
|
|
1814
|
+
role: "alertdialog",
|
|
1815
|
+
accent,
|
|
1816
|
+
size,
|
|
1817
|
+
title,
|
|
1818
|
+
icon,
|
|
1819
|
+
"aria-describedby": children === void 0 ? void 0 : descriptionId,
|
|
1820
|
+
testID,
|
|
1821
|
+
footer,
|
|
1822
|
+
onClose: onDismiss,
|
|
1823
|
+
children: children === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(Text, { nativeID: descriptionId, className: "text-base text-muted", children })
|
|
1824
|
+
}
|
|
1825
|
+
);
|
|
1826
|
+
}
|
|
1827
|
+
function QuestionAlertDialog(props) {
|
|
1828
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AlertDialog, { ...props, icon: /* @__PURE__ */ jsxRuntime.jsx(QuestionRegularIcon.QuestionRegularIcon, {}) });
|
|
1829
|
+
}
|
|
1830
|
+
function WarningAlertDialog(props) {
|
|
1831
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AlertDialog, { ...props, icon: /* @__PURE__ */ jsxRuntime.jsx(WarningRegularIcon.WarningRegularIcon, {}) });
|
|
1832
|
+
}
|
|
1833
|
+
function InfoAlertDialog(props) {
|
|
1834
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AlertDialog, { ...props, icon: /* @__PURE__ */ jsxRuntime.jsx(InfoRegularIcon.InfoRegularIcon, {}) });
|
|
1835
|
+
}
|
|
1836
|
+
function SuccessAlertDialog(props) {
|
|
1837
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AlertDialog, { ...props, icon: /* @__PURE__ */ jsxRuntime.jsx(CheckRegularIcon.CheckRegularIcon, {}) });
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1620
1840
|
const inputVariants = tailwindVariants.tv(
|
|
1621
1841
|
{
|
|
1622
1842
|
base: [
|
|
@@ -2334,6 +2554,7 @@ function ExternalLink({
|
|
|
2334
2554
|
exports.SafeAreaProvider = reactNativeSafeAreaContext.SafeAreaProvider;
|
|
2335
2555
|
exports.useSafeAreaInsets = reactNativeSafeAreaContext.useSafeAreaInsets;
|
|
2336
2556
|
exports.AccentScope = AccentScope;
|
|
2557
|
+
exports.AlertDialog = AlertDialog;
|
|
2337
2558
|
exports.AlouetteDecorator = AlouetteDecorator;
|
|
2338
2559
|
exports.AlouetteProvider = AlouetteProvider;
|
|
2339
2560
|
exports.Badge = Badge;
|
|
@@ -2351,16 +2572,19 @@ exports.GradientScrollView = GradientScrollView;
|
|
|
2351
2572
|
exports.HStack = HStack;
|
|
2352
2573
|
exports.Icon = Icon;
|
|
2353
2574
|
exports.IconButton = IconButton;
|
|
2575
|
+
exports.InfoAlertDialog = InfoAlertDialog;
|
|
2354
2576
|
exports.InfoMessage = InfoMessage;
|
|
2355
2577
|
exports.InputText = InputText;
|
|
2356
2578
|
exports.InteractiveBox = InteractiveBox;
|
|
2357
2579
|
exports.InternalLinkButton = InternalLinkButton;
|
|
2358
2580
|
exports.Message = Message;
|
|
2581
|
+
exports.Modal = Modal;
|
|
2359
2582
|
exports.Paragraph = Paragraph;
|
|
2360
2583
|
exports.PresenceList = PresenceList;
|
|
2361
2584
|
exports.PresenceOne = PresenceOne;
|
|
2362
2585
|
exports.PressableBox = PressableBox;
|
|
2363
2586
|
exports.PressableListItem = PressableListItem;
|
|
2587
|
+
exports.QuestionAlertDialog = QuestionAlertDialog;
|
|
2364
2588
|
exports.SafeAreaBox = SafeAreaBox;
|
|
2365
2589
|
exports.ScopedTheme = ScopedTheme;
|
|
2366
2590
|
exports.ScrollView = ScrollView;
|
|
@@ -2373,6 +2597,7 @@ exports.StoryContainer = StoryContainer;
|
|
|
2373
2597
|
exports.StoryDecorator = StoryDecorator;
|
|
2374
2598
|
exports.StoryGrid = StoryGrid;
|
|
2375
2599
|
exports.StoryTitle = StoryTitle;
|
|
2600
|
+
exports.SuccessAlertDialog = SuccessAlertDialog;
|
|
2376
2601
|
exports.Surface = Surface;
|
|
2377
2602
|
exports.Switch = Switch;
|
|
2378
2603
|
exports.SwitchBreakpointsUsingDisplayNone = SwitchBreakpointsUsingDisplayNone;
|
|
@@ -2381,6 +2606,7 @@ exports.Text = Text;
|
|
|
2381
2606
|
exports.TextArea = TextArea;
|
|
2382
2607
|
exports.VStack = VStack;
|
|
2383
2608
|
exports.View = View;
|
|
2609
|
+
exports.WarningAlertDialog = WarningAlertDialog;
|
|
2384
2610
|
exports.WarningMessage = WarningMessage;
|
|
2385
2611
|
exports.animationDurationsMs = animationDurationsMs;
|
|
2386
2612
|
exports.styled = styled;
|