@react-cupertino-ui/action-sheet 1.0.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/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Anderson Lima
4
+
5
+ This project is inspired by Apple's design principles but is not affiliated with, endorsed, or sponsored by Apple Inc.
6
+
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
package/dist/index.css ADDED
@@ -0,0 +1,182 @@
1
+ .react-cupertino-ui-action-sheet__overlay {
2
+ position: fixed;
3
+ inset: 0;
4
+ z-index: 50;
5
+ background: rgba(0, 0, 0, 0.4);
6
+ backdrop-filter: blur(4px);
7
+ animation: overlayShow 150ms cubic-bezier(0.16, 1, 0.3, 1);
8
+ }
9
+ .react-cupertino-ui-action-sheet__overlay[data-state=closed] {
10
+ animation: overlayHide 150ms cubic-bezier(0.16, 1, 0.3, 1);
11
+ }
12
+ .react-cupertino-ui-action-sheet__content {
13
+ position: fixed;
14
+ bottom: 0;
15
+ left: 0;
16
+ right: 0;
17
+ z-index: 51;
18
+ display: flex;
19
+ flex-direction: column;
20
+ padding: 10px;
21
+ outline: none;
22
+ max-width: 600px;
23
+ margin: 0 auto;
24
+ animation: contentShow 300ms cubic-bezier(0.16, 1, 0.3, 1);
25
+ }
26
+ .react-cupertino-ui-action-sheet__content[data-state=closed] {
27
+ animation: contentHide 300ms cubic-bezier(0.16, 1, 0.3, 1);
28
+ }
29
+ .react-cupertino-ui-action-sheet__group {
30
+ display: flex;
31
+ flex-direction: column;
32
+ overflow: hidden;
33
+ }
34
+ .react-cupertino-ui-action-sheet__header {
35
+ background: rgba(255, 255, 255, 0.82);
36
+ backdrop-filter: blur(20px) saturate(180%);
37
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
38
+ padding: 14px 16px;
39
+ text-align: center;
40
+ border-top-left-radius: 14px;
41
+ border-top-right-radius: 14px;
42
+ }
43
+ @media (prefers-color-scheme: dark) {
44
+ .react-cupertino-ui-action-sheet__header {
45
+ background: rgba(30, 30, 30, 0.82);
46
+ border-bottom: 1px solid rgba(255, 255, 255, 0.1);
47
+ }
48
+ }
49
+ .react-cupertino-ui-action-sheet__header:only-child {
50
+ border-radius: 14px;
51
+ border-bottom: none;
52
+ }
53
+ .react-cupertino-ui-action-sheet__header + .react-cupertino-ui-action-sheet__action {
54
+ border-top-left-radius: 0;
55
+ border-top-right-radius: 0;
56
+ }
57
+ .react-cupertino-ui-action-sheet__title {
58
+ font-size: 13px;
59
+ font-weight: 600;
60
+ color: var(--muted-foreground);
61
+ margin: 0 0 4px;
62
+ }
63
+ .react-cupertino-ui-action-sheet__description {
64
+ font-size: 13px;
65
+ color: var(--muted-foreground);
66
+ margin: 0;
67
+ }
68
+ .react-cupertino-ui-action-sheet__action {
69
+ display: flex;
70
+ align-items: center;
71
+ justify-content: center;
72
+ width: 100%;
73
+ padding: 18px;
74
+ font-size: 20px;
75
+ color: var(--color-blue);
76
+ background: rgba(255, 255, 255, 0.82);
77
+ backdrop-filter: blur(20px) saturate(180%);
78
+ border: none;
79
+ border-top: 1px solid rgba(0, 0, 0, 0.1);
80
+ cursor: pointer;
81
+ transition: background-color 0.2s;
82
+ user-select: none;
83
+ }
84
+ @media (prefers-color-scheme: dark) {
85
+ .react-cupertino-ui-action-sheet__action {
86
+ background: rgba(30, 30, 30, 0.82);
87
+ border-top: 1px solid rgba(255, 255, 255, 0.1);
88
+ }
89
+ }
90
+ .react-cupertino-ui-action-sheet__action:first-child {
91
+ border-radius: 14px;
92
+ border-top: none;
93
+ }
94
+ .react-cupertino-ui-action-sheet__action:last-of-type {
95
+ border-bottom-left-radius: 14px;
96
+ border-bottom-right-radius: 14px;
97
+ }
98
+ .react-cupertino-ui-action-sheet__action:not(:last-of-type) {
99
+ border-bottom-left-radius: 0;
100
+ border-bottom-right-radius: 0;
101
+ }
102
+ .react-cupertino-ui-action-sheet__action:active {
103
+ background: rgba(255, 255, 255, 0.6);
104
+ }
105
+ @media (prefers-color-scheme: dark) {
106
+ .react-cupertino-ui-action-sheet__action:active {
107
+ background: rgba(50, 50, 50, 0.6);
108
+ }
109
+ }
110
+ .react-cupertino-ui-action-sheet__action.destructive {
111
+ color: var(--color-red);
112
+ }
113
+ .react-cupertino-ui-action-sheet__action .action-icon {
114
+ margin-right: 10px;
115
+ display: flex;
116
+ align-items: center;
117
+ }
118
+ .react-cupertino-ui-action-sheet__action .action-label {
119
+ font-weight: 400;
120
+ }
121
+ .react-cupertino-ui-action-sheet__cancel {
122
+ margin-top: 8px;
123
+ width: 100%;
124
+ padding: 18px;
125
+ font-size: 20px;
126
+ font-weight: 600;
127
+ color: var(--color-blue);
128
+ background: rgba(255, 255, 255, 0.95);
129
+ border-radius: 14px;
130
+ border: none;
131
+ cursor: pointer;
132
+ }
133
+ @media (prefers-color-scheme: dark) {
134
+ .react-cupertino-ui-action-sheet__cancel {
135
+ background: rgba(44, 44, 46, 0.95);
136
+ }
137
+ }
138
+ .react-cupertino-ui-action-sheet__cancel:active {
139
+ background: rgba(255, 255, 255, 0.8);
140
+ }
141
+ @media (prefers-color-scheme: dark) {
142
+ .react-cupertino-ui-action-sheet__cancel:active {
143
+ background: rgba(50, 50, 50, 0.8);
144
+ }
145
+ }
146
+
147
+ @keyframes overlayShow {
148
+ from {
149
+ opacity: 0;
150
+ }
151
+ to {
152
+ opacity: 1;
153
+ }
154
+ }
155
+ @keyframes overlayHide {
156
+ from {
157
+ opacity: 1;
158
+ }
159
+ to {
160
+ opacity: 0;
161
+ }
162
+ }
163
+ @keyframes contentShow {
164
+ from {
165
+ opacity: 0;
166
+ transform: translateY(100%);
167
+ }
168
+ to {
169
+ opacity: 1;
170
+ transform: translateY(0);
171
+ }
172
+ }
173
+ @keyframes contentHide {
174
+ from {
175
+ opacity: 1;
176
+ transform: translateY(0);
177
+ }
178
+ to {
179
+ opacity: 0;
180
+ transform: translateY(100%);
181
+ }
182
+ }
@@ -0,0 +1,23 @@
1
+ import * as React from "react";
2
+ import * as DialogPrimitive from "@radix-ui/react-dialog";
3
+ import "./index.scss";
4
+ declare const ActionSheetRoot: React.FC<DialogPrimitive.DialogProps>;
5
+ declare const ActionSheetTrigger: React.ForwardRefExoticComponent<DialogPrimitive.DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
6
+ interface ActionSheetContentProps extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {
7
+ glass?: boolean;
8
+ }
9
+ declare const ActionSheetContent: React.ForwardRefExoticComponent<ActionSheetContentProps & React.RefAttributes<HTMLDivElement>>;
10
+ declare const ActionSheetTitle: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogTitleProps & React.RefAttributes<HTMLHeadingElement>, "ref"> & React.RefAttributes<HTMLHeadingElement>>;
11
+ declare const ActionSheetDescription: React.ForwardRefExoticComponent<Omit<DialogPrimitive.DialogDescriptionProps & React.RefAttributes<HTMLParagraphElement>, "ref"> & React.RefAttributes<HTMLParagraphElement>>;
12
+ interface ActionSheetActionProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
13
+ destructive?: boolean;
14
+ disabled?: boolean;
15
+ onSelect?: () => void;
16
+ icon?: React.ReactNode;
17
+ }
18
+ declare const ActionSheetAction: React.ForwardRefExoticComponent<ActionSheetActionProps & React.RefAttributes<HTMLButtonElement>>;
19
+ interface ActionSheetCancelProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
20
+ }
21
+ declare const ActionSheetCancel: React.ForwardRefExoticComponent<ActionSheetCancelProps & React.RefAttributes<HTMLButtonElement>>;
22
+ declare const ActionSheetHeader: ({ className, children }: React.HTMLAttributes<HTMLDivElement>) => import("react/jsx-runtime").JSX.Element;
23
+ export { ActionSheetRoot as ActionSheet, ActionSheetTrigger, ActionSheetContent, ActionSheetAction, ActionSheetCancel, ActionSheetTitle, ActionSheetDescription, ActionSheetHeader, };
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import * as DialogPrimitive from "@radix-ui/react-dialog";
5
+ import { cn } from "@react-cupertino-ui/shared/lib/utils";
6
+ import "./index.scss";
7
+ const ActionSheetRoot = DialogPrimitive.Root;
8
+ const ActionSheetTrigger = DialogPrimitive.Trigger;
9
+ const ActionSheetPortal = DialogPrimitive.Portal;
10
+ const ActionSheetOverlay = React.forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Overlay, { ref: ref, className: cn("react-cupertino-ui-action-sheet__overlay", className), ...props })));
11
+ ActionSheetOverlay.displayName = DialogPrimitive.Overlay.displayName;
12
+ const ActionSheetContent = React.forwardRef(({ className, children, glass = true, ...props }, ref) => (_jsxs(ActionSheetPortal, { children: [_jsx(ActionSheetOverlay, {}), _jsx(DialogPrimitive.Content, { ref: ref, className: cn("react-cupertino-ui-action-sheet__content", glass && "glass", className), ...props, children: _jsx("div", { className: "react-cupertino-ui-action-sheet__group", children: children }) })] })));
13
+ ActionSheetContent.displayName = DialogPrimitive.Content.displayName;
14
+ const ActionSheetTitle = React.forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Title, { ref: ref, className: cn("react-cupertino-ui-action-sheet__title", className), ...props })));
15
+ ActionSheetTitle.displayName = DialogPrimitive.Title.displayName;
16
+ const ActionSheetDescription = React.forwardRef(({ className, ...props }, ref) => (_jsx(DialogPrimitive.Description, { ref: ref, className: cn("react-cupertino-ui-action-sheet__description", className), ...props })));
17
+ ActionSheetDescription.displayName = DialogPrimitive.Description.displayName;
18
+ const ActionSheetAction = React.forwardRef(({ className, destructive, disabled, onSelect, icon, children, ...props }, ref) => {
19
+ return (_jsx(DialogPrimitive.Close, { asChild: true, children: _jsxs("button", { ref: ref, type: "button", className: cn("react-cupertino-ui-action-sheet__action", destructive && "destructive", className), disabled: disabled, onClick: onSelect, ...props, children: [icon && _jsx("span", { className: "action-icon", children: icon }), _jsx("span", { className: "action-label", children: children })] }) }));
20
+ });
21
+ ActionSheetAction.displayName = "ActionSheetAction";
22
+ const ActionSheetCancel = React.forwardRef(({ className, children, ...props }, ref) => {
23
+ return (_jsx(DialogPrimitive.Close, { asChild: true, children: _jsx("button", { ref: ref, type: "button", className: cn("react-cupertino-ui-action-sheet__cancel", className), ...props, children: children }) }));
24
+ });
25
+ ActionSheetCancel.displayName = "ActionSheetCancel";
26
+ // Helper component for Header/Message area
27
+ const ActionSheetHeader = ({ className, children }) => (_jsx("div", { className: cn("react-cupertino-ui-action-sheet__header", className), children: children }));
28
+ export { ActionSheetRoot as ActionSheet, ActionSheetTrigger, ActionSheetContent, ActionSheetAction, ActionSheetCancel, ActionSheetTitle, ActionSheetDescription, ActionSheetHeader, };
@@ -0,0 +1,184 @@
1
+ @use "@/styles/mixins/glass" as glass;
2
+
3
+ .react-cupertino-ui-action-sheet {
4
+
5
+ &__overlay {
6
+ position: fixed;
7
+ inset: 0;
8
+ z-index: 50;
9
+ background: rgba(0, 0, 0, 0.4);
10
+ backdrop-filter: blur(4px);
11
+ animation: overlayShow 150ms cubic-bezier(0.16, 1, 0.3, 1);
12
+
13
+ &[data-state="closed"] {
14
+ animation: overlayHide 150ms cubic-bezier(0.16, 1, 0.3, 1);
15
+ }
16
+ }
17
+
18
+ &__content {
19
+ position: fixed;
20
+ bottom: 0;
21
+ left: 0;
22
+ right: 0;
23
+ z-index: 51;
24
+ display: flex;
25
+ flex-direction: column;
26
+ padding: 10px;
27
+ outline: none;
28
+ max-width: 600px;
29
+ margin: 0 auto;
30
+
31
+ // Animation
32
+ animation: contentShow 300ms cubic-bezier(0.16, 1, 0.3, 1);
33
+
34
+ &[data-state="closed"] {
35
+ animation: contentHide 300ms cubic-bezier(0.16, 1, 0.3, 1);
36
+ }
37
+ }
38
+
39
+ &__group {
40
+ display: flex;
41
+ flex-direction: column;
42
+ overflow: hidden;
43
+ }
44
+
45
+ &__header {
46
+ background: rgba(255, 255, 255, 0.82);
47
+ backdrop-filter: blur(20px) saturate(180%);
48
+ border-bottom: 1px solid rgba(0, 0, 0, 0.1);
49
+ padding: 14px 16px;
50
+ text-align: center;
51
+ border-top-left-radius: 14px;
52
+ border-top-right-radius: 14px;
53
+
54
+ @media (prefers-color-scheme: dark) {
55
+ background: rgba(30, 30, 30, 0.82);
56
+ border-bottom: 1px solid rgba(255, 255, 255, 0.1);
57
+ }
58
+
59
+ &:only-child {
60
+ border-radius: 14px;
61
+ border-bottom: none;
62
+ }
63
+
64
+ + .react-cupertino-ui-action-sheet__action {
65
+ border-top-left-radius: 0;
66
+ border-top-right-radius: 0;
67
+ }
68
+ }
69
+
70
+ &__title {
71
+ font-size: 13px;
72
+ font-weight: 600;
73
+ color: var(--muted-foreground);
74
+ margin: 0 0 4px;
75
+ }
76
+
77
+ &__description {
78
+ font-size: 13px;
79
+ color: var(--muted-foreground);
80
+ margin: 0;
81
+ }
82
+
83
+ &__action {
84
+ display: flex;
85
+ align-items: center;
86
+ justify-content: center;
87
+ width: 100%;
88
+ padding: 18px;
89
+ font-size: 20px;
90
+ color: var(--color-blue);
91
+ background: rgba(255, 255, 255, 0.82);
92
+ backdrop-filter: blur(20px) saturate(180%);
93
+ border: none;
94
+ border-top: 1px solid rgba(0, 0, 0, 0.1);
95
+ cursor: pointer;
96
+ transition: background-color 0.2s;
97
+ user-select: none;
98
+
99
+ @media (prefers-color-scheme: dark) {
100
+ background: rgba(30, 30, 30, 0.82);
101
+ border-top: 1px solid rgba(255, 255, 255, 0.1);
102
+ }
103
+
104
+ &:first-child {
105
+ border-radius: 14px;
106
+ border-top: none;
107
+ }
108
+
109
+ &:last-of-type {
110
+ border-bottom-left-radius: 14px;
111
+ border-bottom-right-radius: 14px;
112
+ }
113
+
114
+ &:not(:last-of-type) {
115
+ border-bottom-left-radius: 0;
116
+ border-bottom-right-radius: 0;
117
+ }
118
+
119
+ &:active {
120
+ background: rgba(255, 255, 255, 0.6);
121
+ @media (prefers-color-scheme: dark) {
122
+ background: rgba(50, 50, 50, 0.6);
123
+ }
124
+ }
125
+
126
+ &.destructive {
127
+ color: var(--color-red);
128
+ }
129
+
130
+ .action-icon {
131
+ margin-right: 10px;
132
+ display: flex;
133
+ align-items: center;
134
+ }
135
+
136
+ .action-label {
137
+ font-weight: 400;
138
+ }
139
+ }
140
+
141
+ &__cancel {
142
+ margin-top: 8px;
143
+ width: 100%;
144
+ padding: 18px;
145
+ font-size: 20px;
146
+ font-weight: 600;
147
+ color: var(--color-blue);
148
+ background: rgba(255, 255, 255, 0.95); // More opaque
149
+ border-radius: 14px;
150
+ border: none;
151
+ cursor: pointer;
152
+
153
+ @media (prefers-color-scheme: dark) {
154
+ background: rgba(44, 44, 46, 0.95);
155
+ }
156
+
157
+ &:active {
158
+ background: rgba(255, 255, 255, 0.8);
159
+ @media (prefers-color-scheme: dark) {
160
+ background: rgba(50, 50, 50, 0.8);
161
+ }
162
+ }
163
+ }
164
+ }
165
+
166
+ @keyframes overlayShow {
167
+ from { opacity: 0; }
168
+ to { opacity: 1; }
169
+ }
170
+
171
+ @keyframes overlayHide {
172
+ from { opacity: 1; }
173
+ to { opacity: 0; }
174
+ }
175
+
176
+ @keyframes contentShow {
177
+ from { opacity: 0; transform: translateY(100%); }
178
+ to { opacity: 1; transform: translateY(0); }
179
+ }
180
+
181
+ @keyframes contentHide {
182
+ from { opacity: 1; transform: translateY(0); }
183
+ to { opacity: 0; transform: translateY(100%); }
184
+ }
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@react-cupertino-ui/action-sheet",
3
+ "version": "1.0.0",
4
+ "description": "ActionSheet component from React Cupertino UI",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "sideEffects": [
13
+ "./dist/**/*.css",
14
+ "./dist/**/*.scss"
15
+ ],
16
+ "scripts": {
17
+ "build": "tsc -p tsconfig.build.json && npm run build:styles",
18
+ "build:styles": "node ../../../scripts/build-styles.mjs"
19
+ },
20
+ "peerDependencies": {
21
+ "react": "^18.3.1",
22
+ "react-dom": "^18.3.1"
23
+ },
24
+ "dependencies": {
25
+ "@radix-ui/react-dialog": "^1.1.1",
26
+ "@react-cupertino-ui/shared": "workspace:*"
27
+ },
28
+ "devDependencies": {
29
+ "typescript": "^5.2.2"
30
+ },
31
+ "gitHead": "3f53987bdb936a331665691b517c2ba9984777f8",
32
+ "publishConfig": {
33
+ "access": "public"
34
+ }
35
+ }