@better-nds/react 0.0.12 → 0.0.13

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.js DELETED
@@ -1,312 +0,0 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { cva } from 'class-variance-authority';
3
- import { Slot } from 'radix-ui';
4
- import clsx$1, { clsx } from 'clsx';
5
- import { twMerge } from 'tailwind-merge';
6
- import 'react';
7
-
8
- function cn(...inputs) {
9
- return twMerge(clsx(inputs));
10
- }
11
-
12
- const buttonVariants = cva("group/button focus-visible:ring-nds-black inline-flex shrink-0 items-center justify-center rounded-sm border bg-clip-padding font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-red-500 aria-invalid:ring-2 aria-invalid:ring-red-500/30 [&_svg]:pointer-events-none [&_svg]:shrink-0", {
13
- variants: {
14
- variant: {
15
- neutral: "",
16
- primary: "",
17
- "secondary-solid": "",
18
- "secondary-outline": "",
19
- subtle: "",
20
- transparent: ""
21
- },
22
- destructive: {
23
- true: "",
24
- false: ""
25
- },
26
- onColor: {
27
- true: "",
28
- false: ""
29
- },
30
- size: {
31
- lg: "h-10 gap-1.5 px-4 text-base has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5 [&_svg:not([class*='size-'])]:size-6",
32
- md: "h-8 gap-1 px-3 text-sm has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-5",
33
- sm: "h-6 gap-1 px-2 text-xs has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-4",
34
- "icon-lg": "size-10 [&_svg:not([class*='size-'])]:size-6",
35
- "icon-md": "size-8 [&_svg:not([class*='size-'])]:size-5",
36
- "icon-sm": "size-6 [&_svg:not([class*='size-'])]:size-4"
37
- }
38
- },
39
- compoundVariants: [
40
- // Default
41
- {
42
- variant: "neutral",
43
- destructive: false,
44
- onColor: false,
45
- class: "bg-button-neutral text-button-neutral-text hover:bg-button-neutral-hover active:bg-button-neutral-pressed border-transparent"
46
- },
47
- {
48
- variant: "primary",
49
- destructive: false,
50
- onColor: false,
51
- class: "bg-button-primary text-button-primary-text hover:bg-button-primary-hover active:bg-button-primary-pressed border-transparent"
52
- },
53
- {
54
- variant: "secondary-solid",
55
- destructive: false,
56
- onColor: false,
57
- class: "bg-button-secondary-solid text-button-secondary-solid-text hover:bg-button-secondary-solid-hover active:bg-button-secondary-solid-pressed border-transparent"
58
- },
59
- {
60
- variant: "secondary-outline",
61
- destructive: false,
62
- onColor: false,
63
- class: "border-button-secondary-outline-border text-button-secondary-outline-text hover:bg-button-secondary-outline-hover hover:border-button-secondary-outline-hover-border active:bg-button-secondary-outline-pressed active:border-button-secondary-outline-pressed-border"
64
- },
65
- {
66
- variant: "subtle",
67
- destructive: false,
68
- onColor: false,
69
- class: "text-button-subtle-text hover:bg-button-subtle-hover active:bg-button-subtle-pressed border-transparent bg-transparent"
70
- },
71
- {
72
- variant: "transparent",
73
- destructive: false,
74
- onColor: false,
75
- class: "text-button-transparent-text hover:text-button-transparent-hover-text active:text-button-transparent-pressed-text border-transparent bg-transparent"
76
- },
77
- // onColor
78
- {
79
- variant: [
80
- "secondary-solid",
81
- "secondary-outline",
82
- "subtle",
83
- "transparent"
84
- ],
85
- destructive: false,
86
- onColor: true,
87
- class: "focus-visible:ring-nds-white"
88
- },
89
- {
90
- variant: [
91
- "neutral",
92
- "primary"
93
- ],
94
- destructive: false,
95
- onColor: true,
96
- class: "bg-nds-white text-nds-black hover:bg-nds-white/80 active:bg-nds-white/60 focus-visible:ring-nds-black border-transparent"
97
- },
98
- {
99
- variant: "secondary-solid",
100
- destructive: false,
101
- onColor: true,
102
- class: "bg-nds-white/20 text-nds-white active:bg-nds-white/40 border-transparent"
103
- },
104
- {
105
- variant: "secondary-outline",
106
- destructive: false,
107
- onColor: true,
108
- class: "border-nds-white/40 text-nds-white hover:bg-nds-white/20 active:bg-nds-white/40"
109
- },
110
- {
111
- variant: "subtle",
112
- destructive: false,
113
- onColor: true,
114
- class: "text-nds-white hover:bg-nds-white/20 active:bg-nds-white/40 border-transparent"
115
- },
116
- {
117
- variant: "transparent",
118
- destructive: false,
119
- onColor: true,
120
- class: "text-nds-white hover:text-nds-primary-400 active:text-nds-primary-300 border-transparent"
121
- },
122
- // Destructive (neutral + primary share styles regardless of onColor)
123
- {
124
- variant: [
125
- "neutral",
126
- "primary",
127
- "secondary-outline",
128
- "subtle",
129
- "transparent"
130
- ],
131
- destructive: true,
132
- class: "focus-visible:ring-nds-white"
133
- },
134
- {
135
- variant: [
136
- "neutral",
137
- "primary"
138
- ],
139
- destructive: true,
140
- class: "bg-nds-error-600 text-nds-white hover:bg-nds-error-700 active:bg-nds-error-900 border-transparent"
141
- },
142
- // Destructive secondary-solid (same regardless of onColor)
143
- {
144
- variant: "secondary-solid",
145
- destructive: true,
146
- class: "bg-nds-error-50 text-nds-error-700 hover:bg-nds-error-100 active:bg-nds-error-200 border-transparent"
147
- },
148
- // Destructive (onColor: false)
149
- {
150
- variant: "secondary-outline",
151
- destructive: true,
152
- onColor: false,
153
- class: "border-nds-error-200 text-nds-error-700 hover:bg-nds-error-100 active:bg-nds-error-200"
154
- },
155
- {
156
- variant: "subtle",
157
- destructive: true,
158
- onColor: false,
159
- class: "text-nds-error-700 hover:bg-nds-error-200 active:bg-nds-error-300 border-transparent"
160
- },
161
- {
162
- variant: "transparent",
163
- destructive: true,
164
- onColor: false,
165
- class: "text-nds-error-600 hover:text-nds-error-700 active:text-nds-error-900 border-transparent"
166
- },
167
- // Destructive + onColor
168
- {
169
- variant: "secondary-outline",
170
- destructive: true,
171
- onColor: true,
172
- class: "border-nds-error-200 text-nds-error-200 hover:text-nds-error-700 hover:bg-nds-error-100 active:bg-nds-error-200"
173
- },
174
- {
175
- variant: "subtle",
176
- destructive: true,
177
- onColor: true,
178
- class: "text-nds-error-200 hover:text-nds-error-700 hover:bg-nds-error-100 active:bg-nds-error-200 border-transparent"
179
- },
180
- {
181
- variant: "transparent",
182
- destructive: true,
183
- onColor: true,
184
- class: "text-nds-error-200 hover:text-nds-error-300 active:text-nds-error-400 border-transparent"
185
- }
186
- ],
187
- defaultVariants: {
188
- variant: "primary",
189
- size: "md",
190
- destructive: false,
191
- onColor: false
192
- }
193
- });
194
- function Button({ className, variant, size, destructive, onColor, asChild = false, ...props }) {
195
- const Comp = asChild ? Slot.Root : "button";
196
- return /*#__PURE__*/ jsx(Comp, {
197
- "data-slot": "button",
198
- "data-variant": variant,
199
- "data-size": size,
200
- className: cn(buttonVariants({
201
- variant,
202
- size,
203
- destructive,
204
- onColor,
205
- className
206
- })),
207
- ...props
208
- });
209
- }
210
-
211
- const LinkVariants = cva("transition-colors", {
212
- variants: {
213
- variant: {
214
- primary: "text-nds-primary-600 hover:text-nds-primary-400 active:text-nds-primary-300 visited:text-nds-primary-800 disabled:text-nds-neutral-400"
215
- },
216
- underline: {
217
- true: "underline",
218
- false: "no-underline"
219
- }
220
- },
221
- defaultVariants: {
222
- variant: "primary",
223
- underline: false
224
- }
225
- });
226
-
227
- const cardVariants = cva("group/card text-nds-black flex flex-col gap-4 overflow-hidden p-4 rounded-2xl", {
228
- variants: {
229
- type: {
230
- stroke: "bg-nds-white border-nds-neutral-300 border"
231
- }
232
- },
233
- defaultVariants: {
234
- type: "stroke"
235
- }
236
- });
237
- function Card({ className, type, ...props }) {
238
- return /*#__PURE__*/ jsx("div", {
239
- "data-slot": "card",
240
- className: cn(cardVariants({
241
- type
242
- }), className),
243
- ...props
244
- });
245
- }
246
- function CardHeader({ className, ...props }) {
247
- return /*#__PURE__*/ jsx("div", {
248
- "data-slot": "card-header",
249
- className: cn("group/card-header @container/card-header grid auto-rows-min items-start gap-1 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]", className),
250
- ...props
251
- });
252
- }
253
- function CardTitle({ className, ...props }) {
254
- return /*#__PURE__*/ jsx("div", {
255
- "data-slot": "card-title",
256
- className: cn("text-base leading-snug font-bold", className),
257
- ...props
258
- });
259
- }
260
- function CardDescription({ className, ...props }) {
261
- return /*#__PURE__*/ jsx("div", {
262
- "data-slot": "card-description",
263
- className: cn("text-sm", className),
264
- ...props
265
- });
266
- }
267
- function CardAction({ className, ...props }) {
268
- return /*#__PURE__*/ jsx("div", {
269
- "data-slot": "card-action",
270
- className: cn("col-start-2 row-span-2 row-start-1 self-start justify-self-end", className),
271
- ...props
272
- });
273
- }
274
- function CardContent({ className, ...props }) {
275
- return /*#__PURE__*/ jsx("div", {
276
- "data-slot": "card-content",
277
- className: cn(className),
278
- ...props
279
- });
280
- }
281
- function CardFooter({ className, ...props }) {
282
- return /*#__PURE__*/ jsx("div", {
283
- "data-slot": "card-footer",
284
- className: cn("flex items-center gap-4", className),
285
- ...props
286
- });
287
- }
288
-
289
- function Input({ className, type, size = "lg", dir, addon, ...props }) {
290
- return /*#__PURE__*/ jsxs("div", {
291
- dir: dir,
292
- role: "group",
293
- className: clsx$1("after:bg-nds-neutral-950 has-aria-invalid:after:bg-nds-error-700 relative flex w-fit justify-center overflow-hidden rounded-sm transition-shadow [--input-border:var(--color-nds-neutral-400)] after:absolute after:bottom-0 after:h-0.5 after:w-0 after:transition-[width] not-active:focus-within:shadow-md focus-within:after:w-full active:after:w-2/5 has-disabled:shadow-none has-disabled:after:w-0 has-aria-invalid:[--input-border:var(--color-nds-error-700)] has-[input:active]:[--input-border:var(--color-nds-neutral-400)] has-[input:hover]:[--input-border:var(--color-nds-neutral-700)]", {
294
- "h-10": size === "lg",
295
- "h-8": size === "md"
296
- }),
297
- children: [
298
- /*#__PURE__*/ jsx("input", {
299
- type: type,
300
- "data-slot": "input",
301
- className: clsx$1("bg-nds-white text-nds-neutral-700 hover:text-nds-black placeholder:text-nds-neutral-500 active:bg-nds-neutral-100 active:text-nds-neutral-700 relative min-w-0 rounded-s-sm border border-e-0 border-(--input-border) ps-2 pe-4 text-base ring-0 transition-colors outline-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50", className),
302
- ...props
303
- }),
304
- addon && /*#__PURE__*/ jsx("div", {
305
- className: "bg-nds-neutral-100 text-nds-neutral-500 flex h-full items-center gap-1 rounded-e-sm border border-s-0 border-(--input-border) px-4 transition-colors",
306
- children: addon
307
- })
308
- ]
309
- });
310
- }
311
-
312
- export { Button, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Input, LinkVariants, cn };