@worldcoin/mini-apps-ui-kit-react 1.0.2 → 1.1.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.
@@ -0,0 +1,23 @@
1
+ import { ImpactStyle, NotificationType } from '../../lib/haptics';
2
+ type HapticPropsBase = {
3
+ children: React.ReactNode;
4
+ asChild?: boolean;
5
+ } & React.HTMLAttributes<HTMLDivElement>;
6
+ type ImpactHapticProps = HapticPropsBase & {
7
+ variant: "impact";
8
+ type: ImpactStyle;
9
+ };
10
+ type NotificationHapticProps = HapticPropsBase & {
11
+ variant: "notification";
12
+ type: NotificationType;
13
+ };
14
+ type SelectionHapticProps = HapticPropsBase & {
15
+ variant: "selection";
16
+ type?: never;
17
+ };
18
+ type HapticProps = ImpactHapticProps | NotificationHapticProps | SelectionHapticProps;
19
+ declare function Haptic({ children, variant, type, asChild, onClick, ...props }: HapticProps): import("react/jsx-runtime").JSX.Element;
20
+ declare namespace Haptic {
21
+ var displayName: string;
22
+ }
23
+ export { Haptic };
@@ -0,0 +1,33 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { Slot } from "../../node_modules/.pnpm/@radix-ui_react-slot@1.1.1_@types_react@18.3.18_react@18.3.1/node_modules/@radix-ui/react-slot/dist/index.js";
4
+ import haptics from "../../lib/haptics.js";
5
+ function Haptic({
6
+ children,
7
+ variant = "selection",
8
+ type,
9
+ asChild,
10
+ onClick,
11
+ ...props
12
+ }) {
13
+ const Component = asChild ? Slot : "div";
14
+ const handleInteraction = (event) => {
15
+ onClick == null ? void 0 : onClick(event);
16
+ switch (variant) {
17
+ case "impact":
18
+ haptics.impact(type);
19
+ break;
20
+ case "notification":
21
+ haptics.notification(type);
22
+ break;
23
+ case "selection":
24
+ haptics.selection();
25
+ break;
26
+ }
27
+ };
28
+ return /* @__PURE__ */ jsx(Component, { onClick: handleInteraction, ...props, children });
29
+ }
30
+ Haptic.displayName = "Haptic";
31
+ export {
32
+ Haptic
33
+ };
@@ -0,0 +1,2 @@
1
+ export { Haptic } from './Haptic';
2
+ export { useHaptics } from './use-haptics';
@@ -0,0 +1,6 @@
1
+ declare function useHaptics(): {
2
+ notification: (type: import('../../lib/haptics').NotificationType) => void;
3
+ selection: () => void;
4
+ impact: (type: import('../../lib/haptics').ImpactStyle) => void;
5
+ };
6
+ export { useHaptics };
@@ -0,0 +1,7 @@
1
+ import haptics from "../../lib/haptics.js";
2
+ function useHaptics() {
3
+ return haptics;
4
+ }
5
+ export {
6
+ useHaptics
7
+ };
package/dist/index.d.ts CHANGED
@@ -34,4 +34,5 @@ export { CountryDrawer } from './components/CountryDrawer';
34
34
  export { ToggleGroupRoot, ToggleGroupItem } from './components/ToggleGroup';
35
35
  export { Tabs, TabItem } from './components/Tabs';
36
36
  export { LiveFeedback } from './components/LiveFeedback';
37
+ export { Haptic, useHaptics } from './components/Haptic';
37
38
  export { default as uiKitTailwindPlugin } from './tailwind';
package/dist/index.js CHANGED
@@ -37,6 +37,8 @@ import { CountryDrawer } from "./components/CountryDrawer/CountryDrawer.js";
37
37
  import { ToggleGroupItem, ToggleGroupRoot } from "./components/ToggleGroup/ToggleGroup.js";
38
38
  import { TabItem, Tabs } from "./components/Tabs/Tabs.js";
39
39
  import { LiveFeedback } from "./components/LiveFeedback/LiveFeedback.js";
40
+ import { Haptic } from "./components/Haptic/Haptic.js";
41
+ import { useHaptics } from "./components/Haptic/use-haptics.js";
40
42
  export {
41
43
  AlertDialog,
42
44
  AlertDialogClose,
@@ -66,6 +68,7 @@ export {
66
68
  DrawerTrigger,
67
69
  Flag,
68
70
  Form,
71
+ Haptic,
69
72
  Input,
70
73
  ListItem,
71
74
  LiveFeedback,
@@ -93,5 +96,6 @@ export {
93
96
  Typography,
94
97
  WalletAddressField,
95
98
  default2 as uiKitTailwindPlugin,
99
+ useHaptics,
96
100
  useToast
97
101
  };
@@ -16,7 +16,7 @@ declare global {
16
16
  declare const haptics: {
17
17
  notification: (type: NotificationType) => void;
18
18
  selection: () => void;
19
- impact: (style: ImpactStyle) => void;
19
+ impact: (type: ImpactStyle) => void;
20
20
  };
21
21
  /**
22
22
  * Wraps a function with haptic feedback
@@ -26,3 +26,4 @@ declare const haptics: {
26
26
  */
27
27
  export declare function withHaptics<T extends (...args: any[]) => any>(fn: T | undefined, hapticFn?: () => void): T;
28
28
  export default haptics;
29
+ export type { NotificationType, ImpactStyle, HapticFeedbackParams };
@@ -18,10 +18,10 @@ const haptics = {
18
18
  hapticsType: "selectionChanged"
19
19
  });
20
20
  },
21
- impact: (style) => {
21
+ impact: (type) => {
22
22
  sendHapticFeedback({
23
23
  hapticsType: "impact",
24
- style
24
+ style: type
25
25
  });
26
26
  }
27
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@worldcoin/mini-apps-ui-kit-react",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -27,6 +27,7 @@
27
27
  "@eslint/js": "^9.13.0",
28
28
  "@storybook/addon-essentials": "^8.4.7",
29
29
  "@storybook/addon-interactions": "^8.4.7",
30
+ "@storybook/addon-mdx-gfm": "^8.6.12",
30
31
  "@storybook/addon-onboarding": "^8.4.7",
31
32
  "@storybook/blocks": "^8.4.7",
32
33
  "@storybook/manager-api": "^8.5.5",
@@ -236,6 +237,10 @@
236
237
  "types": "./dist/components/CircularState/index.d.ts",
237
238
  "default": "./dist/components/CircularState/index.js"
238
239
  },
240
+ "./Haptic": {
241
+ "types": "./dist/components/Haptic/index.d.ts",
242
+ "default": "./dist/components/Haptic/index.js"
243
+ },
239
244
  "./tailwind": {
240
245
  "types": "./dist/tailwind/index.d.ts",
241
246
  "import": "./dist/tailwind/index.js",