@react-cupertino-ui/suggestion-chip 0.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,138 @@
1
+ .react-cupertino-ui-suggestion-chip {
2
+ --chip-height: 2.35rem;
3
+ --chip-padding-inline: 1rem;
4
+ --chip-gap: 0.45rem;
5
+ --chip-foreground: var(--button-foreground-color, hsl(var(--foreground, 20 14.3% 4.1%)));
6
+ position: relative;
7
+ display: inline-flex;
8
+ align-items: center;
9
+ justify-content: center;
10
+ gap: var(--chip-gap);
11
+ border-radius: 999px;
12
+ border: none;
13
+ background: transparent;
14
+ padding-inline: var(--chip-padding-inline);
15
+ height: var(--chip-height);
16
+ min-height: var(--chip-height);
17
+ color: var(--chip-foreground);
18
+ font-size: 0.9rem;
19
+ font-weight: 500;
20
+ letter-spacing: 0.01em;
21
+ cursor: pointer;
22
+ -webkit-tap-highlight-color: transparent;
23
+ transition: background 220ms ease, box-shadow 220ms ease, color 220ms ease, transform 220ms ease, filter 220ms ease;
24
+ isolation: isolate;
25
+ }
26
+ .react-cupertino-ui-suggestion-chip:focus-visible {
27
+ outline: none;
28
+ box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.25), 0 0 1px rgba(255, 255, 255, 0.9);
29
+ }
30
+ .react-cupertino-ui-suggestion-chip:focus {
31
+ outline: none;
32
+ }
33
+ .react-cupertino-ui-suggestion-chip:disabled, .react-cupertino-ui-suggestion-chip[aria-disabled=true] {
34
+ opacity: 0.55;
35
+ cursor: not-allowed;
36
+ }
37
+ .react-cupertino-ui-suggestion-chip[data-active=true] {
38
+ transform: translateY(-1px);
39
+ }
40
+ .react-cupertino-ui-suggestion-chip[data-loading=true] {
41
+ cursor: progress;
42
+ }
43
+ .react-cupertino-ui-suggestion-chip__icon, .react-cupertino-ui-suggestion-chip__trailing, .react-cupertino-ui-suggestion-chip__spinner {
44
+ width: 1.15rem;
45
+ height: 1.15rem;
46
+ display: inline-flex;
47
+ align-items: center;
48
+ justify-content: center;
49
+ color: inherit;
50
+ }
51
+ .react-cupertino-ui-suggestion-chip__label {
52
+ white-space: nowrap;
53
+ }
54
+ .react-cupertino-ui-suggestion-chip__spinner {
55
+ border-radius: inherit;
56
+ border: 2px solid color-mix(in srgb, currentColor, transparent 50%);
57
+ border-top-color: currentColor;
58
+ animation: chip-spin 0.85s linear infinite;
59
+ }
60
+ .react-cupertino-ui-suggestion-chip.variant-glass {
61
+ background: rgba(255, 255, 255, 0.65);
62
+ backdrop-filter: blur(var(--glass-blur, 28px)) saturate(var(--glass-saturation, 180%));
63
+ -webkit-backdrop-filter: blur(var(--glass-blur, 28px)) saturate(var(--glass-saturation, 180%));
64
+ border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.18));
65
+ box-shadow: var(--glass-shadow, 0 8px 32px rgba(0, 0, 0, 0.12));
66
+ position: relative;
67
+ overflow: hidden;
68
+ }
69
+ .react-cupertino-ui-suggestion-chip.variant-glass::before {
70
+ content: "";
71
+ position: absolute;
72
+ inset: 0;
73
+ background: var(--glass-highlight, linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, transparent 55%));
74
+ border-radius: inherit;
75
+ opacity: var(--glass-highlight-opacity, 0.95);
76
+ pointer-events: none;
77
+ mix-blend-mode: screen;
78
+ }
79
+ .react-cupertino-ui-suggestion-chip.variant-glass {
80
+ background: var(--glass-surface, rgba(255, 255, 255, 0.72));
81
+ }
82
+ .react-cupertino-ui-suggestion-chip.variant-glass:hover:not(:disabled) {
83
+ background: var(--glass-surface-hover, rgba(255, 255, 255, 0.85));
84
+ box-shadow: 0 12px 35px rgba(6, 6, 8, 0.14);
85
+ }
86
+ .react-cupertino-ui-suggestion-chip.variant-glass[data-active=true] {
87
+ filter: brightness(0.98);
88
+ }
89
+ .react-cupertino-ui-suggestion-chip.variant-outline {
90
+ background: transparent;
91
+ border: 1px solid var(--glass-border-strong, rgba(255, 255, 255, 0.4));
92
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
93
+ }
94
+ .react-cupertino-ui-suggestion-chip.variant-outline:hover:not(:disabled) {
95
+ background: rgba(255, 255, 255, 0.08);
96
+ }
97
+ .react-cupertino-ui-suggestion-chip.variant-ghost {
98
+ background: transparent;
99
+ color: var(--color-blue, #0a84ff);
100
+ }
101
+ .react-cupertino-ui-suggestion-chip.variant-ghost:hover:not(:disabled) {
102
+ background: rgba(0, 122, 255, 0.08);
103
+ }
104
+ .react-cupertino-ui-suggestion-chip.variant-secondary {
105
+ background: rgba(15, 15, 15, 0.05);
106
+ color: color-mix(in srgb, #0b0b0b, white 10%);
107
+ }
108
+ .react-cupertino-ui-suggestion-chip.variant-secondary:hover:not(:disabled) {
109
+ background: rgba(15, 15, 15, 0.08);
110
+ }
111
+ .react-cupertino-ui-suggestion-chip.size-sm {
112
+ --chip-height: 2rem;
113
+ --chip-padding-inline: 0.85rem;
114
+ font-size: 0.85rem;
115
+ }
116
+ .react-cupertino-ui-suggestion-chip.size-default {
117
+ --chip-height: 2.35rem;
118
+ }
119
+ .react-cupertino-ui-suggestion-chip.has-icon .react-cupertino-ui-suggestion-chip__label {
120
+ font-weight: 600;
121
+ }
122
+ .react-cupertino-ui-suggestion-chip.has-trailing-icon {
123
+ padding-inline-end: calc(var(--chip-padding-inline) - 0.2rem);
124
+ }
125
+
126
+ @keyframes chip-spin {
127
+ to {
128
+ transform: rotate(360deg);
129
+ }
130
+ }
131
+ @media (prefers-reduced-motion: reduce) {
132
+ .react-cupertino-ui-suggestion-chip {
133
+ transition-duration: 0.15s;
134
+ }
135
+ .react-cupertino-ui-suggestion-chip[data-active=true] {
136
+ transform: none;
137
+ }
138
+ }
@@ -0,0 +1,13 @@
1
+ import * as React from "react";
2
+ import { BaseProps } from "@react-cupertino-ui/shared/lib/interfaces/BaseProps";
3
+ import "./index.scss";
4
+ type NativeChipProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "color" | "className" | "children">;
5
+ export interface SuggestionChipProps extends BaseProps<HTMLButtonElement>, NativeChipProps {
6
+ asChild?: boolean;
7
+ icon?: React.ReactNode;
8
+ trailingIcon?: React.ReactNode;
9
+ active?: boolean;
10
+ loading?: boolean;
11
+ }
12
+ declare const SuggestionChip: React.ForwardRefExoticComponent<SuggestionChipProps & React.RefAttributes<HTMLButtonElement>>;
13
+ export { SuggestionChip };
package/dist/index.js ADDED
@@ -0,0 +1,49 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import * as React from "react";
3
+ import { Slot } from "@radix-ui/react-slot";
4
+ import { cn } from "@react-cupertino-ui/shared/lib/utils";
5
+ import { BaseVariants } from "@react-cupertino-ui/shared/lib/interfaces/BaseProps";
6
+ import "./index.scss";
7
+ const chipClasses = (props) => {
8
+ const { variant, size, className, active, loading, hasIcon, hasTrailing } = props;
9
+ return BaseVariants("react-cupertino-ui-suggestion-chip", {
10
+ variant,
11
+ size,
12
+ className: cn(active && "is-active", loading && "is-loading", hasIcon && "has-icon", hasTrailing && "has-trailing-icon", className),
13
+ }, {
14
+ variants: {
15
+ variant: {
16
+ glass: "variant-glass",
17
+ outline: "variant-outline",
18
+ ghost: "variant-ghost",
19
+ secondary: "variant-secondary",
20
+ default: "variant-glass",
21
+ },
22
+ size: {
23
+ default: "size-default",
24
+ sm: "size-sm",
25
+ },
26
+ },
27
+ defaultVariants: {
28
+ variant: "glass",
29
+ size: "default",
30
+ },
31
+ });
32
+ };
33
+ const SuggestionChip = React.forwardRef((props, ref) => {
34
+ const { asChild = false, icon, trailingIcon, active = false, loading = false, disabled, children, className, variant, size, ...rest } = props;
35
+ const Comp = asChild ? Slot : "button";
36
+ const isDisabled = Boolean(disabled || loading);
37
+ const classes = chipClasses({
38
+ variant,
39
+ size,
40
+ className,
41
+ active,
42
+ loading,
43
+ hasIcon: Boolean(icon),
44
+ hasTrailing: Boolean(trailingIcon),
45
+ });
46
+ return (_jsxs(Comp, { ref: ref, className: cn(classes), "data-active": active ? "true" : undefined, "data-loading": loading ? "true" : undefined, disabled: !asChild ? isDisabled : undefined, "aria-disabled": asChild && isDisabled ? "true" : undefined, ...rest, children: [loading ? (_jsx("span", { className: "react-cupertino-ui-suggestion-chip__spinner", "aria-hidden": "true" })) : icon ? (_jsx("span", { className: "react-cupertino-ui-suggestion-chip__icon", "aria-hidden": "true", children: icon })) : null, children && (_jsx("span", { className: "react-cupertino-ui-suggestion-chip__label", children: children })), trailingIcon ? (_jsx("span", { className: "react-cupertino-ui-suggestion-chip__trailing", "aria-hidden": "true", children: trailingIcon })) : null] }));
47
+ });
48
+ SuggestionChip.displayName = "SuggestionChip";
49
+ export { SuggestionChip };
@@ -0,0 +1,150 @@
1
+ @use "@/styles/mixins/glass" as glass;
2
+
3
+ .react-cupertino-ui-suggestion-chip {
4
+ --chip-height: 2.35rem;
5
+ --chip-padding-inline: 1rem;
6
+ --chip-gap: 0.45rem;
7
+ --chip-foreground: var(--button-foreground-color, hsl(var(--foreground, 20 14.3% 4.1%)));
8
+
9
+ position: relative;
10
+ display: inline-flex;
11
+ align-items: center;
12
+ justify-content: center;
13
+ gap: var(--chip-gap);
14
+ border-radius: 999px;
15
+ border: none;
16
+ background: transparent;
17
+ padding-inline: var(--chip-padding-inline);
18
+ height: var(--chip-height);
19
+ min-height: var(--chip-height);
20
+ color: var(--chip-foreground);
21
+ font-size: 0.9rem;
22
+ font-weight: 500;
23
+ letter-spacing: 0.01em;
24
+ cursor: pointer;
25
+ -webkit-tap-highlight-color: transparent;
26
+ transition: background 220ms ease, box-shadow 220ms ease, color 220ms ease,
27
+ transform 220ms ease, filter 220ms ease;
28
+ isolation: isolate;
29
+
30
+ &:focus-visible {
31
+ outline: none;
32
+ box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.25), 0 0 1px rgba(255, 255, 255, 0.9);
33
+ }
34
+
35
+ &:focus {
36
+ outline: none;
37
+ }
38
+
39
+ &:disabled,
40
+ &[aria-disabled="true"] {
41
+ opacity: 0.55;
42
+ cursor: not-allowed;
43
+ }
44
+
45
+ &[data-active="true"] {
46
+ transform: translateY(-1px);
47
+ }
48
+
49
+ &[data-loading="true"] {
50
+ cursor: progress;
51
+ }
52
+
53
+ &__icon,
54
+ &__trailing,
55
+ &__spinner {
56
+ width: 1.15rem;
57
+ height: 1.15rem;
58
+ display: inline-flex;
59
+ align-items: center;
60
+ justify-content: center;
61
+ color: inherit;
62
+ }
63
+
64
+ &__label {
65
+ white-space: nowrap;
66
+ }
67
+
68
+ &__spinner {
69
+ border-radius: inherit;
70
+ border: 2px solid color-mix(in srgb, currentColor, transparent 50%);
71
+ border-top-color: currentColor;
72
+ animation: chip-spin 0.85s linear infinite;
73
+ }
74
+
75
+ &.variant-glass {
76
+ @include glass.glass-panel(light, var(--glass-blur, 28px), 0.65);
77
+ background: var(--glass-surface, rgba(255, 255, 255, 0.72));
78
+
79
+ &:hover:not(:disabled) {
80
+ background: var(--glass-surface-hover, rgba(255, 255, 255, 0.85));
81
+ box-shadow: 0 12px 35px rgba(6, 6, 8, 0.14);
82
+ }
83
+
84
+ &[data-active="true"] {
85
+ filter: brightness(0.98);
86
+ }
87
+ }
88
+
89
+ &.variant-outline {
90
+ background: transparent;
91
+ border: 1px solid var(--glass-border-strong, rgba(255, 255, 255, 0.4));
92
+ box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
93
+
94
+ &:hover:not(:disabled) {
95
+ background: rgba(255, 255, 255, 0.08);
96
+ }
97
+ }
98
+
99
+ &.variant-ghost {
100
+ background: transparent;
101
+ color: var(--color-blue, #0a84ff);
102
+
103
+ &:hover:not(:disabled) {
104
+ background: rgba(0, 122, 255, 0.08);
105
+ }
106
+ }
107
+
108
+ &.variant-secondary {
109
+ background: rgba(15, 15, 15, 0.05);
110
+ color: color-mix(in srgb, #0b0b0b, white 10%);
111
+
112
+ &:hover:not(:disabled) {
113
+ background: rgba(15, 15, 15, 0.08);
114
+ }
115
+ }
116
+
117
+ &.size-sm {
118
+ --chip-height: 2rem;
119
+ --chip-padding-inline: 0.85rem;
120
+ font-size: 0.85rem;
121
+ }
122
+
123
+ &.size-default {
124
+ --chip-height: 2.35rem;
125
+ }
126
+
127
+ &.has-icon .react-cupertino-ui-suggestion-chip__label {
128
+ font-weight: 600;
129
+ }
130
+
131
+ &.has-trailing-icon {
132
+ padding-inline-end: calc(var(--chip-padding-inline) - 0.2rem);
133
+ }
134
+ }
135
+
136
+ @keyframes chip-spin {
137
+ to {
138
+ transform: rotate(360deg);
139
+ }
140
+ }
141
+
142
+ @media (prefers-reduced-motion: reduce) {
143
+ .react-cupertino-ui-suggestion-chip {
144
+ transition-duration: 0.15s;
145
+
146
+ &[data-active="true"] {
147
+ transform: none;
148
+ }
149
+ }
150
+ }
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@react-cupertino-ui/suggestion-chip",
3
+ "version": "0.0.0",
4
+ "description": "SuggestionChip 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-slot": "^1.1.0",
26
+ "@react-cupertino-ui/shared": "0.0.0"
27
+ },
28
+ "devDependencies": {
29
+ "typescript": "^5.2.2"
30
+ },
31
+ "gitHead": "a6b07a7a8a0ab6f4c80884b6fb9d5eb16ee6da1d",
32
+ "publishConfig": {
33
+ "access": "public"
34
+ }
35
+ }