@hyphen/hyphen-components 2.22.0 → 2.23.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/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export * from './components/Button/Button';
5
5
  export * from './components/Card/Card';
6
6
  export * from './components/CheckboxInput/components/Checkbox';
7
7
  export * from './components/CheckboxInput/CheckboxInput';
8
+ export * from './components/Collapsible/Collapsible';
8
9
  export * from './components/DateInput/DateInput';
9
10
  export * from './components/DatePicker/DatePicker';
10
11
  export * from './components/Details/Details';
@@ -1,5 +1,5 @@
1
1
  import { BorderRadiusSize, Breakpoint, BreakpointSizeWithBase } from '../types';
2
- export declare const ICON_NAMES: ("add" | "alarm-disable" | "alarm" | "analytics" | "arrow-down" | "arrow-left" | "arrow-right" | "arrow-up" | "arrows-maximize" | "at" | "ban" | "block" | "blocks" | "book-open" | "c-add" | "c-check" | "c-delete" | "c-in-progress" | "c-info" | "c-question" | "c-remove" | "c-warning" | "calendar-create" | "calendar" | "camera" | "caret-down" | "caret-left" | "caret-right" | "caret-sm-down" | "caret-sm-left" | "caret-sm-right" | "caret-sm-up" | "caret-up" | "chart-bar" | "chart-line" | "chat" | "check" | "checkbox-btn-checked" | "checkbox-btn-indeterminate" | "checkbox-btn" | "circle-filled" | "circle" | "clipboard" | "cloud" | "contact" | "copy-document" | "dashboard" | "database" | "document" | "dots" | "download" | "electricity-bolt" | "exclamation-mark" | "eye-slash" | "eye" | "filter" | "flag" | "gear" | "grab" | "hash-mark" | "heart-o" | "heart" | "home" | "info" | "integrations" | "key" | "launch-app" | "lightbulb" | "link" | "list" | "lock" | "logo-env" | "logo-link" | "logo-toggle" | "mail" | "menu" | "minus" | "moon" | "paperclip" | "path-intersect" | "pause" | "pc" | "pencil" | "phone" | "photo" | "play" | "radio-btn-checked" | "radio-btn-unchecked" | "refresh" | "remove" | "rewind" | "search" | "send" | "settings" | "skip" | "stack" | "star-o" | "star" | "stopwatch" | "subtract" | "sun" | "t-warning" | "tag" | "terminal" | "time-alarm" | "time-clock" | "trash" | "unlocked" | "upload" | "user-create" | "user" | "users" | "wifi-off" | "wifi" | "zoom-in" | "zoom-out")[];
2
+ export declare const ICON_NAMES: ("add" | "alarm-disable" | "alarm" | "analytics" | "arrow-down" | "arrow-left" | "arrow-right" | "arrow-up" | "arrows-maximize" | "at" | "ban" | "block" | "blocks" | "book-open" | "c-add" | "c-check" | "c-delete" | "c-in-progress" | "c-info" | "c-question" | "c-remove" | "c-warning" | "calendar-create" | "calendar" | "camera" | "caret-down" | "caret-left" | "caret-right" | "caret-sm-down" | "caret-sm-left" | "caret-sm-right" | "caret-sm-up" | "caret-up-down" | "caret-up" | "chart-bar" | "chart-line" | "chat" | "check" | "checkbox-btn-checked" | "checkbox-btn-indeterminate" | "checkbox-btn" | "circle-filled" | "circle" | "clipboard" | "cloud" | "contact" | "copy-document" | "dashboard" | "database" | "dock-left" | "document" | "dots" | "download" | "electricity-bolt" | "exclamation-mark" | "eye-slash" | "eye" | "filter" | "flag" | "gear" | "grab" | "hash-mark" | "heart-o" | "heart" | "home" | "info" | "integrations" | "key" | "launch-app" | "lightbulb" | "link" | "list" | "lock" | "logo-env" | "logo-link" | "logo-toggle" | "logout" | "mail" | "menu" | "minus" | "moon" | "paperclip" | "path-intersect" | "pause" | "pc" | "pencil" | "phone" | "photo" | "play" | "radio-btn-checked" | "radio-btn-unchecked" | "refresh" | "remove" | "rewind" | "search" | "send" | "settings" | "skip" | "stack" | "star-o" | "star" | "stopwatch" | "subtract" | "sun" | "t-warning" | "tag" | "terminal" | "time-alarm" | "time-clock" | "trash" | "unlocked" | "upload" | "user-create" | "user" | "users" | "wifi-off" | "wifi" | "zoom-in" | "zoom-out")[];
3
3
  export declare const BORDER_RADIUS_OPTIONS: BorderRadiusSize[];
4
4
  export declare const BORDER_SIZE_OPTIONS: ("0" | "sm" | "md" | "lg")[];
5
5
  export declare const BREAKPOINT_OPTIONS: BreakpointSizeWithBase[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyphen/hyphen-components",
3
- "version": "2.22.0",
3
+ "version": "2.23.0",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "@hyphen"
@@ -65,13 +65,13 @@
65
65
  "@chromatic-com/storybook": "^1.8.0",
66
66
  "@semantic-release/commit-analyzer": "^11.1.0",
67
67
  "@size-limit/preset-small-lib": "^11.1.4",
68
- "@storybook/addon-essentials": "^8.2.9",
68
+ "@storybook/addon-essentials": "^8.4.2",
69
69
  "@storybook/addon-interactions": "^8.3.5",
70
70
  "@storybook/addon-themes": "^8.2.9",
71
71
  "@storybook/blocks": "^8.2.9",
72
72
  "@storybook/manager-api": "^8.2.9",
73
73
  "@storybook/react": "^8.2.9",
74
- "@storybook/react-vite": "^8.2.9",
74
+ "@storybook/react-vite": "^8.4.2",
75
75
  "@storybook/test": "^8.3.5",
76
76
  "@storybook/theming": "^8.2.9",
77
77
  "@testing-library/jest-dom": "^6.5.0",
@@ -79,6 +79,7 @@
79
79
  "@testing-library/user-event": "^14.5.2",
80
80
  "@tsconfig/recommended": "^1.0.7",
81
81
  "@tsconfig/vite-react": "^3.0.2",
82
+ "@types/node": "^22.9.0",
82
83
  "@types/react": "^18.3.5",
83
84
  "@types/react-datepicker": "^6.2.0",
84
85
  "@types/react-dom": "^18.3.0",
@@ -121,8 +122,9 @@
121
122
  "@rollup/rollup-linux-x64-gnu": "^4.21.2"
122
123
  },
123
124
  "dependencies": {
124
- "@hyphen/hyphen-design-tokens": "^4.14.0",
125
+ "@hyphen/hyphen-design-tokens": "^4.17.0",
125
126
  "@popperjs/core": "^2.11.8",
127
+ "@radix-ui/react-collapsible": "^1.1.1",
126
128
  "@types/react-modal": "^3.16.3",
127
129
  "classnames": "^2.5.1",
128
130
  "date-fns": "^2.16.1",
@@ -0,0 +1,21 @@
1
+ import { Canvas, Meta, ArgTypes } from '@storybook/blocks';
2
+ import { Collapsible, CollapsibleTrigger } from './Collapsible';
3
+ import * as Stories from './Collapsible.stories';
4
+
5
+ <Meta of={Stories} />
6
+
7
+ # Collapsible
8
+
9
+ Collapsible components are used to hide or show content based on user interaction.
10
+
11
+ This component is extended from [Radix](https://www.radix-ui.com/primitives/docs/components/collapsible).
12
+
13
+ [API Reference](https://www.radix-ui.com/primitives/docs/components/collapsible#api-reference)
14
+
15
+ <Canvas of={Stories.Uncontrolled} />
16
+
17
+ ## Controlled
18
+
19
+ The `isOpen` prop can be used to control the state of the collapsible component.
20
+
21
+ <Canvas of={Stories.Controlled} />
@@ -0,0 +1,104 @@
1
+ import React from 'react';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+ import {
4
+ Collapsible,
5
+ CollapsibleTrigger,
6
+ CollapsibleContent,
7
+ } from './Collapsible';
8
+ import { Button } from '../Button/Button';
9
+ import { Box } from '../Box/Box';
10
+ import { userEvent, within, expect } from '@storybook/test';
11
+
12
+ const meta: Meta<typeof Collapsible> = {
13
+ title: 'Components/Collapsible',
14
+ component: Collapsible,
15
+ };
16
+
17
+ export default meta;
18
+ type Story = StoryObj<typeof Collapsible>;
19
+
20
+ export const Uncontrolled = () => (
21
+ <Collapsible>
22
+ <CollapsibleTrigger asChild>
23
+ <Button variant="primary">Can I use this in my project?</Button>
24
+ </CollapsibleTrigger>
25
+ <CollapsibleContent>
26
+ Yes. Free to use for personal and commercial projects. No attribution
27
+ required.
28
+ </CollapsibleContent>
29
+ </Collapsible>
30
+ );
31
+
32
+ export function Controlled() {
33
+ const [isOpen, setIsOpen] = React.useState(false);
34
+
35
+ return (
36
+ <Collapsible
37
+ open={isOpen}
38
+ onOpenChange={setIsOpen}
39
+ className="display-flex flex-direction-column g-sm w-9xl"
40
+ >
41
+ <Box
42
+ alignItems="center"
43
+ justifyContent="space-between"
44
+ padding="sm 0"
45
+ direction="row"
46
+ >
47
+ <h4 className="text-sm font-semibold">
48
+ @peduarte starred 3 repositories
49
+ </h4>
50
+ <CollapsibleTrigger asChild>
51
+ <Button
52
+ variant="tertiary"
53
+ iconPrefix={isOpen ? 'remove' : 'caret-up-down'}
54
+ size="sm"
55
+ aria-label="toggle"
56
+ />
57
+ </CollapsibleTrigger>
58
+ </Box>
59
+ <Box
60
+ fontFamily="monospace"
61
+ radius="sm"
62
+ padding="md"
63
+ fontSize="sm"
64
+ borderWidth="sm"
65
+ borderColor="default"
66
+ >
67
+ @radix-ui/primitives
68
+ </Box>
69
+ <CollapsibleContent className="display-flex flex-direction-column g-sm">
70
+ <Box
71
+ fontFamily="monospace"
72
+ radius="sm"
73
+ padding="md"
74
+ fontSize="sm"
75
+ borderWidth="sm"
76
+ borderColor="default"
77
+ >
78
+ @radix-ui/colors
79
+ </Box>
80
+ <Box
81
+ fontFamily="monospace"
82
+ radius="sm"
83
+ padding="md"
84
+ fontSize="sm"
85
+ borderWidth="sm"
86
+ borderColor="default"
87
+ >
88
+ @stitches/react
89
+ </Box>
90
+ </CollapsibleContent>
91
+ </Collapsible>
92
+ );
93
+ }
94
+
95
+ export const ClickOpenCollapsible: Story = {
96
+ play: async ({ canvasElement, mount }) => {
97
+ await mount(<Controlled />);
98
+ const canvas = within(canvasElement);
99
+
100
+ await userEvent.click(canvas.getByLabelText('toggle'));
101
+
102
+ await expect(canvas.getByText('@radix-ui/colors')).toBeInTheDocument();
103
+ },
104
+ };
@@ -0,0 +1,11 @@
1
+ 'use client';
2
+
3
+ import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
4
+
5
+ const Collapsible = CollapsiblePrimitive.Root;
6
+
7
+ const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger;
8
+
9
+ const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent;
10
+
11
+ export { Collapsible, CollapsibleTrigger, CollapsibleContent };
@@ -4,7 +4,7 @@ import { BREAKPOINTS } from '../../lib/tokens';
4
4
  const desktopBreakpoint = BREAKPOINTS.find((b) => b.name === 'desktop');
5
5
  const MOBILE_BREAKPOINT = desktopBreakpoint ? desktopBreakpoint.minWidth : 0; // min width in pixels
6
6
 
7
- export function useIsMobile(): Boolean {
7
+ export function useIsMobile(): boolean {
8
8
  const [isMobile, setIsMobile] = React.useState<boolean | undefined>(
9
9
  undefined
10
10
  );
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ export * from './components/Button/Button';
5
5
  export * from './components/Card/Card';
6
6
  export * from './components/CheckboxInput/components/Checkbox';
7
7
  export * from './components/CheckboxInput/CheckboxInput';
8
+ export * from './components/Collapsible/Collapsible';
8
9
  export * from './components/DateInput/DateInput';
9
10
  export * from './components/DatePicker/DatePicker';
10
11
  export * from './components/Details/Details';