@hive-ui/side-modal 0.3.1

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,150 @@
1
+ import { BoxProps } from "@hive-ui/box";
2
+ import { NonModalDialogPrimitivePopoverInitialState, NonModalDialogPrimitiveStateReturn, NonModalDialogPrimitiveStateReturn as SideModalStateReturn } from "@hive-ui/non-modal-dialog-primitive";
3
+ import * as _$react from "react";
4
+ import { ReactNode } from "react";
5
+ import { ButtonProps } from "@hive-ui/button";
6
+ import { HeadingProps } from "@hive-ui/heading";
7
+ //#region src/SideModal.d.ts
8
+ type SideModalProps = Pick<BoxProps<"div">, "element" | "children"> & {
9
+ /**
10
+ * Title of the dialog for screen readers.
11
+ *
12
+ * @type {string}
13
+ * @memberof SideModalProps
14
+ */
15
+ "aria-label": string;
16
+ /**
17
+ * Set to false to disable closing the SideModal when the "Escape" key is pressed.
18
+ *
19
+ * @default true
20
+ * @type {boolean}
21
+ * @memberof SideModalProps
22
+ */
23
+ hideOnEsc?: boolean;
24
+ };
25
+ declare const SideModal: _$react.ForwardRefExoticComponent<Pick<BoxProps<"div">, "children" | "element"> & {
26
+ /**
27
+ * Title of the dialog for screen readers.
28
+ *
29
+ * @type {string}
30
+ * @memberof SideModalProps
31
+ */
32
+ "aria-label": string;
33
+ /**
34
+ * Set to false to disable closing the SideModal when the "Escape" key is pressed.
35
+ *
36
+ * @default true
37
+ * @type {boolean}
38
+ * @memberof SideModalProps
39
+ */
40
+ hideOnEsc?: boolean;
41
+ } & _$react.RefAttributes<HTMLElement>>;
42
+ //#endregion
43
+ //#region src/SideModalButton.d.ts
44
+ type SideModalButtonProps = Omit<ButtonProps, "as"> & {
45
+ /**
46
+ * The id of the SideModal that the button controls
47
+ *
48
+ * @type {string}
49
+ */
50
+ id?: string;
51
+ };
52
+ declare const SideModalButton: _$react.ForwardRefExoticComponent<Omit<ButtonProps, "as"> & {
53
+ /**
54
+ * The id of the SideModal that the button controls
55
+ *
56
+ * @type {string}
57
+ */
58
+ id?: string;
59
+ } & _$react.RefAttributes<HTMLElement>>;
60
+ //#endregion
61
+ //#region src/SideModalHeader.d.ts
62
+ type SideModalHeaderProps = Pick<BoxProps<"div">, "element" | "children"> & {
63
+ /**
64
+ * The dismiss button text label
65
+ *
66
+ * @default "close"
67
+ * @type {string}
68
+ * @memberof SideModalHeaderProps
69
+ */
70
+ i18nDismissLabel?: string;
71
+ };
72
+ declare const SideModalHeader: _$react.ForwardRefExoticComponent<Pick<BoxProps<"div">, "children" | "element"> & {
73
+ /**
74
+ * The dismiss button text label
75
+ *
76
+ * @default "close"
77
+ * @type {string}
78
+ * @memberof SideModalHeaderProps
79
+ */
80
+ i18nDismissLabel?: string;
81
+ } & _$react.RefAttributes<HTMLDivElement>>;
82
+ //#endregion
83
+ //#region src/SideModalHeading.d.ts
84
+ type SideModalHeadingProps = Omit<HeadingProps, "marginBottom" | "variant" | "as"> & {
85
+ /**
86
+ * The element the `SideModalHeading` will render
87
+ *
88
+ * @default "h2"
89
+ * @type {("h1" | "h2" | "h3" | "h4" | "h5" | "h6")}
90
+ * @memberof SideModalHeadingProps
91
+ */
92
+ as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
93
+ };
94
+ declare const SideModalHeading: _$react.ForwardRefExoticComponent<Omit<HeadingProps, "as" | "marginBottom" | "variant"> & {
95
+ /**
96
+ * The element the `SideModalHeading` will render
97
+ *
98
+ * @default "h2"
99
+ * @type {("h1" | "h2" | "h3" | "h4" | "h5" | "h6")}
100
+ * @memberof SideModalHeadingProps
101
+ */
102
+ as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
103
+ } & _$react.RefAttributes<HTMLElement>>;
104
+ //#endregion
105
+ //#region src/SideModalContainer.d.ts
106
+ type SideModalContainerProps = NonModalDialogPrimitivePopoverInitialState & {
107
+ children: NonNullable<ReactNode>;
108
+ /**
109
+ * Returned state from `useSideModalState` hook
110
+ *
111
+ * @type {SideModalStateReturn}
112
+ * @memberof SideModalContainerProps
113
+ */
114
+ state?: SideModalStateReturn;
115
+ };
116
+ declare const SideModalContainer: _$react.NamedExoticComponent<SideModalContainerProps>;
117
+ //#endregion
118
+ //#region src/SideModalBody.d.ts
119
+ type SideModalBodyProps = Pick<BoxProps<"div">, "element" | "children">;
120
+ declare const SideModalBody: _$react.ForwardRefExoticComponent<SideModalBodyProps & _$react.RefAttributes<HTMLElement>>;
121
+ //#endregion
122
+ //#region src/SideModalFooter.d.ts
123
+ type SideModalFooterProps = Pick<BoxProps<"div">, "element" | "children">;
124
+ declare const SideModalFooter: _$react.ForwardRefExoticComponent<SideModalFooterProps & _$react.RefAttributes<HTMLElement>>;
125
+ //#endregion
126
+ //#region src/SideModalFooterActions.d.ts
127
+ type JustifyOptions = "flex-start" | "flex-end" | "space-between";
128
+ type SideModalFooterActionsProps = Pick<BoxProps<"div">, "element" | "children"> & {
129
+ /**
130
+ * Sets the `justify-content` CSS property.
131
+ *
132
+ * @type {JustifyOptions}
133
+ * @memberof SideModalFooterActionsProps
134
+ */
135
+ justifyContent?: JustifyOptions;
136
+ };
137
+ declare const SideModalFooterActions: _$react.ForwardRefExoticComponent<Pick<BoxProps<"div">, "children" | "element"> & {
138
+ /**
139
+ * Sets the `justify-content` CSS property.
140
+ *
141
+ * @type {JustifyOptions}
142
+ * @memberof SideModalFooterActionsProps
143
+ */
144
+ justifyContent?: JustifyOptions;
145
+ } & _$react.RefAttributes<HTMLElement>>;
146
+ //#endregion
147
+ //#region src/useSideModalState.d.ts
148
+ declare const useSideModalState: (options: NonModalDialogPrimitivePopoverInitialState) => NonModalDialogPrimitiveStateReturn;
149
+ //#endregion
150
+ export { SideModal, SideModalBody, type SideModalBodyProps, SideModalButton, type SideModalButtonProps, SideModalContainer, type SideModalContainerProps, SideModalFooter, SideModalFooterActions, type SideModalFooterActionsProps, type SideModalFooterProps, SideModalHeader, type SideModalHeaderProps, SideModalHeading, type SideModalHeadingProps, type SideModalProps, type SideModalStateReturn, useSideModalState };
package/dist/index.mjs ADDED
@@ -0,0 +1,198 @@
1
+ import { animated, useTransition } from "@hive-ui/animation-library";
2
+ import { Box } from "@hive-ui/box";
3
+ import { hiveBaseStyles } from "@hive-ui/theme";
4
+ import { styled } from "@hive-ui/css-library";
5
+ import { NonModalDialogDisclosurePrimitive, NonModalDialogPrimitive, useNonModalDialogPrimitiveState } from "@hive-ui/non-modal-dialog-primitive";
6
+ import { createContext, forwardRef, memo, useContext } from "react";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ import { Button } from "@hive-ui/button";
9
+ import { CloseIcon } from "@hive-ui/icons/CloseIcon";
10
+ import { ScreenReaderOnly } from "@hive-ui/screen-reader-only";
11
+ import { Heading } from "@hive-ui/heading";
12
+ //#region src/SideModalContext.ts
13
+ const SideModalContext = createContext({});
14
+ //#endregion
15
+ //#region src/SideModal.tsx
16
+ const AnimatedBox = animated(Box);
17
+ const StyledBox = styled(Box)(hiveBaseStyles);
18
+ const getAnimationStates = () => ({
19
+ from: {
20
+ opacity: 0,
21
+ transform: `translateX(100%)`
22
+ },
23
+ enter: {
24
+ opacity: 1,
25
+ transform: `translateX(0%)`
26
+ },
27
+ leave: {
28
+ opacity: 0,
29
+ transform: `translateX(100%)`
30
+ },
31
+ config: {
32
+ mass: .5,
33
+ tension: 220,
34
+ friction: 20
35
+ }
36
+ });
37
+ const SideModal = forwardRef(({ element = "SIDE_MODAL", hideOnEsc, children, ...props }, ref) => {
38
+ const dialog = useContext(SideModalContext);
39
+ const transitions = useTransition(dialog.visible, getAnimationStates());
40
+ return /* @__PURE__ */ jsx(NonModalDialogPrimitive, {
41
+ ...dialog,
42
+ ...props,
43
+ preventBodyScroll: false,
44
+ hideOnClickOutside: false,
45
+ hideOnEsc,
46
+ element: `${element}_CONTAINER`,
47
+ ref,
48
+ as: Box,
49
+ zIndex: "zIndex80",
50
+ position: "fixed",
51
+ top: "0 !important",
52
+ right: "0 !important",
53
+ bottom: "0 !important",
54
+ left: "auto !important",
55
+ transform: "none !important",
56
+ _focus: { outline: "none" },
57
+ children: /* @__PURE__ */ jsx(StyledBox, { children: transitions((styles, item) => {
58
+ return item && /* @__PURE__ */ jsx(AnimatedBox, {
59
+ style: styles,
60
+ element,
61
+ display: "grid",
62
+ gridTemplateRows: "auto 1fr auto",
63
+ height: "100vh",
64
+ backgroundColor: "colorBackgroundWeaker",
65
+ boxShadow: "shadowElevationLeft20",
66
+ width: "51rem",
67
+ children
68
+ });
69
+ }) })
70
+ });
71
+ });
72
+ //#endregion
73
+ //#region src/SideModalButton.tsx
74
+ const SideModalButton = forwardRef(({ element = "SIDE_MODAL_BUTTON", children, ...props }, ref) => {
75
+ return /* @__PURE__ */ jsx(NonModalDialogDisclosurePrimitive, {
76
+ element,
77
+ ...useContext(SideModalContext),
78
+ ...props,
79
+ as: Button,
80
+ ref,
81
+ children
82
+ });
83
+ });
84
+ //#endregion
85
+ //#region src/SideModalHeader.tsx
86
+ const SideModalHeader = forwardRef(({ element = "SIDE_MODAL_HEADER", i18nDismissLabel = "close", children, ...props }, ref) => {
87
+ const { hide } = useContext(SideModalContext);
88
+ return /* @__PURE__ */ jsxs(Box, {
89
+ ...props,
90
+ ref,
91
+ paddingRight: "space90",
92
+ paddingLeft: "space90",
93
+ paddingTop: "space90",
94
+ element,
95
+ display: "flex",
96
+ flexDirection: "row",
97
+ alignItems: "flex-start",
98
+ children: [/* @__PURE__ */ jsx(Box, {
99
+ display: "flex",
100
+ flexGrow: 1,
101
+ marginRight: "space70",
102
+ children
103
+ }), /* @__PURE__ */ jsxs(Button, {
104
+ element: `${element}_CLOSE_BUTTON`,
105
+ variant: "secondary_icon",
106
+ size: "reset",
107
+ onClick: hide,
108
+ children: [/* @__PURE__ */ jsx(CloseIcon, {
109
+ element: `${element}_CLOSE_ICON`,
110
+ decorative: true,
111
+ size: "sizeIcon50"
112
+ }), /* @__PURE__ */ jsx(ScreenReaderOnly, { children: i18nDismissLabel })]
113
+ })]
114
+ });
115
+ });
116
+ //#endregion
117
+ //#region src/SideModalHeading.tsx
118
+ const SideModalHeading = forwardRef(({ element = "SIDE_MODAL_HEADING", as = "h2", children, ...props }, ref) => {
119
+ return /* @__PURE__ */ jsx(Heading, {
120
+ ...props,
121
+ as,
122
+ element,
123
+ marginBottom: "space0",
124
+ variant: "heading30",
125
+ ref,
126
+ children
127
+ });
128
+ });
129
+ //#endregion
130
+ //#region src/SideModalContainer.tsx
131
+ const BaseSideModalContainer = ({ gutter, placement, modal, children, state, ...initialState }) => {
132
+ const dialog = state || useNonModalDialogPrimitiveState({
133
+ modal: true,
134
+ unstable_fixed: true,
135
+ ...initialState
136
+ });
137
+ return /* @__PURE__ */ jsx(SideModalContext.Provider, {
138
+ value: { ...dialog },
139
+ children
140
+ });
141
+ };
142
+ BaseSideModalContainer.displayName = "BaseSideModalContainer";
143
+ const SideModalContainer = memo(BaseSideModalContainer);
144
+ SideModalContainer.displayName = "SideModalContainer";
145
+ //#endregion
146
+ //#region src/SideModalBody.tsx
147
+ const SideModalBody = forwardRef(({ element = "SIDE_MODAL_BODY", children, ...props }, ref) => {
148
+ return /* @__PURE__ */ jsx(Box, {
149
+ ...props,
150
+ element,
151
+ ref,
152
+ overflowY: "auto",
153
+ padding: "space90",
154
+ children
155
+ });
156
+ });
157
+ //#endregion
158
+ //#region src/SideModalFooter.tsx
159
+ const SideModalFooter = forwardRef(({ element = "SIDE_MODAL_FOOTER", children, ...props }, ref) => {
160
+ return /* @__PURE__ */ jsx(Box, {
161
+ ...props,
162
+ as: "div",
163
+ element,
164
+ ref,
165
+ paddingRight: "space90",
166
+ paddingLeft: "space90",
167
+ paddingBottom: "space90",
168
+ display: "flex",
169
+ children
170
+ });
171
+ });
172
+ //#endregion
173
+ //#region src/SideModalFooterActions.tsx
174
+ const SideModalFooterActions = forwardRef(({ element = "SIDE_MODAL_FOOTER_ACTIONS", justifyContent = "flex-start", children, ...props }, ref) => {
175
+ return /* @__PURE__ */ jsx(Box, {
176
+ ...props,
177
+ display: "flex",
178
+ justifyContent,
179
+ flexWrap: "wrap",
180
+ flexGrow: 1,
181
+ element,
182
+ columnGap: "space50",
183
+ alignItems: "center",
184
+ ref,
185
+ children
186
+ });
187
+ });
188
+ //#endregion
189
+ //#region src/useSideModalState.ts
190
+ const useSideModalState = (options) => {
191
+ return useNonModalDialogPrimitiveState({
192
+ modal: true,
193
+ unstable_fixed: true,
194
+ ...options
195
+ });
196
+ };
197
+ //#endregion
198
+ export { SideModal, SideModalBody, SideModalButton, SideModalContainer, SideModalFooter, SideModalFooterActions, SideModalHeader, SideModalHeading, useSideModalState };
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@hive-ui/side-modal",
3
+ "version": "0.3.1",
4
+ "description": "Hive UI Side Modal Component",
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "type": "module",
9
+ "exports": {
10
+ ".": "./dist/index.mjs",
11
+ "./package.json": "./package.json"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "scripts": {
17
+ "build": "vp pack",
18
+ "dev": "vp pack --watch",
19
+ "test": "vp test",
20
+ "check": "vp check",
21
+ "prepublishOnly": "vp run build"
22
+ },
23
+ "dependencies": {
24
+ "@hive-ui/box": "^0.3.1",
25
+ "@hive-ui/button": "^0.3.1",
26
+ "@hive-ui/heading": "^0.3.1",
27
+ "@hive-ui/icons": "^0.3.1",
28
+ "@hive-ui/screen-reader-only": "^0.3.1",
29
+ "@hive-ui/animation-library": "^0.3.1",
30
+ "@hive-ui/theme": "^0.3.1",
31
+ "@hive-ui/css-library": "^0.3.1",
32
+ "@hive-ui/non-modal-dialog-primitive": "^0.3.1",
33
+ "@hive-ui/style-props": "^0.3.1"
34
+ },
35
+ "devDependencies": {
36
+ "@types/node": "^25.6.2",
37
+ "@typescript/native-preview": "7.0.0-dev.20260509.2",
38
+ "bumpp": "^11.1.0",
39
+ "typescript": "^6.0.3",
40
+ "vite-plus": "^0.1.20",
41
+ "vitest": "npm:@voidzero-dev/vite-plus-test@^0.1.20"
42
+ },
43
+ "peerDependencies": {
44
+ "react": "19.2.6"
45
+ }
46
+ }