@travelallfly/ui 0.3.0 → 0.5.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.cjs +279 -2
- package/dist/index.d.cts +51 -1
- package/dist/index.d.ts +51 -1
- package/dist/index.js +273 -1
- package/dist/utils.cjs +77 -2
- package/dist/utils.d.cts +9 -1
- package/dist/utils.d.ts +9 -1
- package/dist/utils.js +75 -0
- package/package.json +4 -1
package/dist/index.cjs
CHANGED
|
@@ -31,7 +31,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/index.ts
|
|
32
32
|
var src_exports = {};
|
|
33
33
|
__export(src_exports, {
|
|
34
|
-
|
|
34
|
+
Badge: () => Badge,
|
|
35
|
+
Banner: () => Banner,
|
|
36
|
+
Button: () => Button,
|
|
37
|
+
Field: () => Field,
|
|
38
|
+
Input: () => Input,
|
|
39
|
+
Select: () => Select
|
|
35
40
|
});
|
|
36
41
|
module.exports = __toCommonJS(src_exports);
|
|
37
42
|
|
|
@@ -201,7 +206,279 @@ var Button = React.forwardRef(
|
|
|
201
206
|
}
|
|
202
207
|
);
|
|
203
208
|
Button.displayName = "Button";
|
|
209
|
+
|
|
210
|
+
// src/components/badge/badge.tsx
|
|
211
|
+
var React2 = __toESM(require("react"), 1);
|
|
212
|
+
var import_class_variance_authority2 = require("class-variance-authority");
|
|
213
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
214
|
+
var badgeVariants = (0, import_class_variance_authority2.cva)(
|
|
215
|
+
"type-label-strong inline-flex h-6 shrink-0 items-center gap-spacing-xs whitespace-nowrap rounded-radius-full px-spacing-md",
|
|
216
|
+
{
|
|
217
|
+
variants: {
|
|
218
|
+
status: {
|
|
219
|
+
success: "bg-status-success-fill text-status-success-text",
|
|
220
|
+
info: "bg-status-info-fill text-status-info-text",
|
|
221
|
+
caution: "bg-status-caution-fill text-status-caution-text",
|
|
222
|
+
error: "bg-status-error-fill text-status-error-text",
|
|
223
|
+
neutral: "bg-status-neutral-fill text-status-neutral-text"
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
defaultVariants: {
|
|
227
|
+
status: "neutral"
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
);
|
|
231
|
+
var Badge = React2.forwardRef(({ className, status, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { ref, className: cn(badgeVariants({ status }), className), ...props }));
|
|
232
|
+
Badge.displayName = "Badge";
|
|
233
|
+
|
|
234
|
+
// src/components/banner/banner.tsx
|
|
235
|
+
var React3 = __toESM(require("react"), 1);
|
|
236
|
+
var import_class_variance_authority3 = require("class-variance-authority");
|
|
237
|
+
var import_lucide_react = require("lucide-react");
|
|
238
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
239
|
+
var bannerVariants = (0, import_class_variance_authority3.cva)(
|
|
240
|
+
"type-body flex items-start gap-spacing-sm rounded-radius-lg border px-spacing-lg py-spacing-md",
|
|
241
|
+
{
|
|
242
|
+
variants: {
|
|
243
|
+
status: {
|
|
244
|
+
info: "border-status-info-border bg-status-info-fill text-status-info-text",
|
|
245
|
+
success: "border-status-success-border bg-status-success-fill text-status-success-text",
|
|
246
|
+
caution: "border-status-caution-border bg-status-caution-fill text-status-caution-text",
|
|
247
|
+
error: "border-status-error-border bg-status-error-fill text-status-error-text"
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
defaultVariants: {
|
|
251
|
+
status: "info"
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
);
|
|
255
|
+
var icons = {
|
|
256
|
+
info: import_lucide_react.Info,
|
|
257
|
+
success: import_lucide_react.CheckCircle2,
|
|
258
|
+
caution: import_lucide_react.AlertTriangle,
|
|
259
|
+
error: import_lucide_react.AlertCircle
|
|
260
|
+
};
|
|
261
|
+
var iconColour = {
|
|
262
|
+
info: "text-status-info-text",
|
|
263
|
+
success: "text-status-success-text",
|
|
264
|
+
caution: "text-status-caution-icon",
|
|
265
|
+
error: "text-status-error-text"
|
|
266
|
+
};
|
|
267
|
+
var Banner = React3.forwardRef(
|
|
268
|
+
({ className, status, title, icon, children, role = "status", ...props }, ref) => {
|
|
269
|
+
const resolved = status ?? "info";
|
|
270
|
+
const Icon2 = icons[resolved];
|
|
271
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { ref, role, className: cn(bannerVariants({ status: resolved }), className), ...props, children: [
|
|
272
|
+
icon === null ? null : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "aria-hidden": "true", className: cn("mt-0.5 flex size-5 shrink-0 items-center", iconColour[resolved]), children: icon ?? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Icon2, { className: "size-5", strokeWidth: 2 }) }),
|
|
273
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: "min-w-0", children: [
|
|
274
|
+
title ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { className: "type-body-strong", children: title }) : null,
|
|
275
|
+
title && children ? " " : null,
|
|
276
|
+
children
|
|
277
|
+
] })
|
|
278
|
+
] });
|
|
279
|
+
}
|
|
280
|
+
);
|
|
281
|
+
Banner.displayName = "Banner";
|
|
282
|
+
|
|
283
|
+
// src/components/field/field.tsx
|
|
284
|
+
var React5 = __toESM(require("react"), 1);
|
|
285
|
+
|
|
286
|
+
// src/components/field/field-context.ts
|
|
287
|
+
var React4 = __toESM(require("react"), 1);
|
|
288
|
+
var FieldContext = React4.createContext(null);
|
|
289
|
+
|
|
290
|
+
// src/components/field/field.tsx
|
|
291
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
292
|
+
var Field = React5.forwardRef(
|
|
293
|
+
({ className, label, helper, error, note, id, children, ...props }, ref) => {
|
|
294
|
+
const generatedId = React5.useId();
|
|
295
|
+
const inputId = id ?? generatedId;
|
|
296
|
+
const messageId = `${inputId}-message`;
|
|
297
|
+
const message = error ?? note ?? helper;
|
|
298
|
+
const context = React5.useMemo(
|
|
299
|
+
() => ({
|
|
300
|
+
id: inputId,
|
|
301
|
+
describedBy: message ? messageId : void 0,
|
|
302
|
+
invalid: Boolean(error),
|
|
303
|
+
prefilled: !error && Boolean(note)
|
|
304
|
+
}),
|
|
305
|
+
[inputId, messageId, message, error, note]
|
|
306
|
+
);
|
|
307
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { ref, className: cn("flex flex-col gap-1.5", className), ...props, children: [
|
|
308
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: inputId, className: "type-label text-text-primary", children: label }),
|
|
309
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldContext.Provider, { value: context, children }),
|
|
310
|
+
message ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
311
|
+
"p",
|
|
312
|
+
{
|
|
313
|
+
id: messageId,
|
|
314
|
+
className: cn(
|
|
315
|
+
"type-label",
|
|
316
|
+
error ? "text-status-error-strong" : note ? "text-status-info-text" : "text-text-muted"
|
|
317
|
+
),
|
|
318
|
+
children: message
|
|
319
|
+
}
|
|
320
|
+
) : null
|
|
321
|
+
] });
|
|
322
|
+
}
|
|
323
|
+
);
|
|
324
|
+
Field.displayName = "Field";
|
|
325
|
+
|
|
326
|
+
// src/components/input/input.tsx
|
|
327
|
+
var React6 = __toESM(require("react"), 1);
|
|
328
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
329
|
+
var inputClasses = [
|
|
330
|
+
"type-body h-12 w-full min-w-0 rounded-radius-md border border-border-strong bg-bg-surface px-spacing-lg",
|
|
331
|
+
"text-text-primary placeholder:text-text-muted transition-colors",
|
|
332
|
+
"hover:border-border-control",
|
|
333
|
+
"focus-visible:border-border-focus focus-visible:shadow-elevation-focus focus-visible:outline-none",
|
|
334
|
+
"focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-border-focus",
|
|
335
|
+
"data-[prefilled=true]:border-status-info-border",
|
|
336
|
+
"aria-[invalid=true]:border-status-error-border aria-[invalid=true]:ring-1 aria-[invalid=true]:ring-inset aria-[invalid=true]:ring-status-error-border",
|
|
337
|
+
"disabled:cursor-not-allowed disabled:border-border-default disabled:bg-bg-sunken disabled:text-text-muted"
|
|
338
|
+
];
|
|
339
|
+
var Input = React6.forwardRef(
|
|
340
|
+
({ className, prefilled, id, "aria-describedby": describedBy, "aria-invalid": invalid, ...props }, ref) => {
|
|
341
|
+
const field = React6.useContext(FieldContext);
|
|
342
|
+
const describedByIds = [field?.describedBy, describedBy].filter(Boolean).join(" ") || void 0;
|
|
343
|
+
const isInvalid = invalid ?? (field?.invalid ? true : void 0);
|
|
344
|
+
const isPrefilled = prefilled ?? field?.prefilled ?? false;
|
|
345
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
346
|
+
"input",
|
|
347
|
+
{
|
|
348
|
+
ref,
|
|
349
|
+
id: id ?? field?.id,
|
|
350
|
+
"aria-describedby": describedByIds,
|
|
351
|
+
"aria-invalid": isInvalid,
|
|
352
|
+
"data-prefilled": isPrefilled || void 0,
|
|
353
|
+
className: cn(inputClasses, className),
|
|
354
|
+
...props
|
|
355
|
+
}
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
);
|
|
359
|
+
Input.displayName = "Input";
|
|
360
|
+
|
|
361
|
+
// src/components/select/select.tsx
|
|
362
|
+
var React7 = __toESM(require("react"), 1);
|
|
363
|
+
var SelectPrimitive = __toESM(require("@radix-ui/react-select"), 1);
|
|
364
|
+
var import_lucide_react2 = require("lucide-react");
|
|
365
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
366
|
+
var EMPTY_VALUE = "__af-select-empty__";
|
|
367
|
+
var selectTriggerClasses = [
|
|
368
|
+
"group type-body flex h-12 w-full min-w-0 items-center justify-between gap-spacing-sm rounded-radius-md border border-border-strong bg-bg-surface px-spacing-lg text-left",
|
|
369
|
+
"text-text-primary transition-colors data-[placeholder]:text-text-muted",
|
|
370
|
+
"hover:border-border-control",
|
|
371
|
+
"focus-visible:border-border-focus focus-visible:shadow-elevation-focus focus-visible:outline-none",
|
|
372
|
+
"focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-border-focus",
|
|
373
|
+
"data-[state=open]:border-border-focus data-[state=open]:shadow-elevation-focus",
|
|
374
|
+
"data-[state=open]:ring-1 data-[state=open]:ring-inset data-[state=open]:ring-border-focus",
|
|
375
|
+
"aria-[invalid=true]:border-status-error-border aria-[invalid=true]:ring-1 aria-[invalid=true]:ring-inset aria-[invalid=true]:ring-status-error-border",
|
|
376
|
+
"disabled:cursor-not-allowed disabled:border-border-default disabled:bg-bg-sunken disabled:text-text-muted"
|
|
377
|
+
];
|
|
378
|
+
var selectContentClasses = "relative z-50 max-h-80 overflow-hidden rounded-radius-lg border border-border-default bg-bg-surface shadow-elevation-floating";
|
|
379
|
+
var selectItemClasses = [
|
|
380
|
+
"type-body relative flex h-11 cursor-pointer select-none items-center gap-spacing-sm rounded-radius-sm px-spacing-md text-text-primary outline-none",
|
|
381
|
+
"data-[highlighted]:data-[state=unchecked]:bg-bg-hover",
|
|
382
|
+
"data-[state=checked]:type-body-strong data-[state=checked]:bg-bg-selected data-[state=checked]:text-text-on-selected",
|
|
383
|
+
"data-[disabled]:cursor-not-allowed data-[disabled]:text-text-muted"
|
|
384
|
+
];
|
|
385
|
+
var Select = React7.forwardRef(
|
|
386
|
+
({
|
|
387
|
+
options,
|
|
388
|
+
value,
|
|
389
|
+
defaultValue,
|
|
390
|
+
onValueChange,
|
|
391
|
+
placeholder,
|
|
392
|
+
name,
|
|
393
|
+
required,
|
|
394
|
+
disabled,
|
|
395
|
+
open,
|
|
396
|
+
defaultOpen,
|
|
397
|
+
onOpenChange,
|
|
398
|
+
className,
|
|
399
|
+
contentClassName,
|
|
400
|
+
id,
|
|
401
|
+
"aria-describedby": describedBy,
|
|
402
|
+
"aria-invalid": invalid,
|
|
403
|
+
...props
|
|
404
|
+
}, ref) => {
|
|
405
|
+
const field = React7.useContext(FieldContext);
|
|
406
|
+
const hasEmptyOption = options.some((option) => option.value === "");
|
|
407
|
+
const toInternal = (next) => next === "" && hasEmptyOption ? EMPTY_VALUE : next;
|
|
408
|
+
const describedByIds = [field?.describedBy, describedBy].filter(Boolean).join(" ") || void 0;
|
|
409
|
+
const isInvalid = invalid ?? (field?.invalid ? true : void 0);
|
|
410
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
411
|
+
SelectPrimitive.Root,
|
|
412
|
+
{
|
|
413
|
+
value: toInternal(value),
|
|
414
|
+
defaultValue: toInternal(defaultValue),
|
|
415
|
+
onValueChange: (next) => onValueChange?.(next === EMPTY_VALUE ? "" : next),
|
|
416
|
+
name,
|
|
417
|
+
required,
|
|
418
|
+
disabled,
|
|
419
|
+
open,
|
|
420
|
+
defaultOpen,
|
|
421
|
+
onOpenChange,
|
|
422
|
+
children: [
|
|
423
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
424
|
+
SelectPrimitive.Trigger,
|
|
425
|
+
{
|
|
426
|
+
ref,
|
|
427
|
+
id: id ?? field?.id,
|
|
428
|
+
"aria-describedby": describedByIds,
|
|
429
|
+
"aria-invalid": isInvalid,
|
|
430
|
+
className: cn(selectTriggerClasses, className),
|
|
431
|
+
...props,
|
|
432
|
+
children: [
|
|
433
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "min-w-0 flex-1 truncate", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectPrimitive.Value, { placeholder }) }),
|
|
434
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
435
|
+
import_lucide_react2.ChevronDown,
|
|
436
|
+
{
|
|
437
|
+
"aria-hidden": "true",
|
|
438
|
+
className: "size-5 shrink-0 text-text-primary transition-transform group-data-[state=open]:rotate-180 group-disabled:text-text-muted"
|
|
439
|
+
}
|
|
440
|
+
) })
|
|
441
|
+
]
|
|
442
|
+
}
|
|
443
|
+
),
|
|
444
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
445
|
+
SelectPrimitive.Content,
|
|
446
|
+
{
|
|
447
|
+
position: "popper",
|
|
448
|
+
sideOffset: 4,
|
|
449
|
+
className: cn(selectContentClasses, contentClassName),
|
|
450
|
+
style: { minWidth: "var(--radix-select-trigger-width)" },
|
|
451
|
+
children: [
|
|
452
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectPrimitive.ScrollUpButton, { className: "flex h-6 items-center justify-center text-text-muted", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react2.ChevronUp, { "aria-hidden": "true", className: "size-4" }) }),
|
|
453
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectPrimitive.Viewport, { className: "flex flex-col p-spacing-sm", children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
454
|
+
SelectPrimitive.Item,
|
|
455
|
+
{
|
|
456
|
+
value: option.value === "" ? EMPTY_VALUE : option.value,
|
|
457
|
+
disabled: option.disabled,
|
|
458
|
+
className: cn(selectItemClasses),
|
|
459
|
+
children: [
|
|
460
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectPrimitive.ItemText, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "min-w-0 flex-1 truncate", children: option.label }) }),
|
|
461
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react2.Check, { "aria-hidden": "true", className: "size-5 shrink-0 text-text-on-selected" }) })
|
|
462
|
+
]
|
|
463
|
+
},
|
|
464
|
+
option.value === "" ? EMPTY_VALUE : option.value
|
|
465
|
+
)) }),
|
|
466
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectPrimitive.ScrollDownButton, { className: "flex h-6 items-center justify-center text-text-muted", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react2.ChevronDown, { "aria-hidden": "true", className: "size-4" }) })
|
|
467
|
+
]
|
|
468
|
+
}
|
|
469
|
+
) })
|
|
470
|
+
]
|
|
471
|
+
}
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
);
|
|
475
|
+
Select.displayName = "Select";
|
|
204
476
|
// Annotate the CommonJS export names for ESM import in node:
|
|
205
477
|
0 && (module.exports = {
|
|
206
|
-
|
|
478
|
+
Badge,
|
|
479
|
+
Banner,
|
|
480
|
+
Button,
|
|
481
|
+
Field,
|
|
482
|
+
Input,
|
|
483
|
+
Select
|
|
207
484
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -14,4 +14,54 @@ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, But
|
|
|
14
14
|
}
|
|
15
15
|
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
declare const badgeVariants: (props?: ({
|
|
18
|
+
status?: "success" | "info" | "caution" | "error" | "neutral" | null | undefined;
|
|
19
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
20
|
+
interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement>, VariantProps<typeof badgeVariants> {
|
|
21
|
+
}
|
|
22
|
+
declare const Badge: React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<HTMLSpanElement>>;
|
|
23
|
+
|
|
24
|
+
declare const bannerVariants: (props?: ({
|
|
25
|
+
status?: "success" | "info" | "caution" | "error" | null | undefined;
|
|
26
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
27
|
+
interface BannerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'>, VariantProps<typeof bannerVariants> {
|
|
28
|
+
title?: React.ReactNode;
|
|
29
|
+
icon?: React.ReactNode | null;
|
|
30
|
+
}
|
|
31
|
+
declare const Banner: React.ForwardRefExoticComponent<BannerProps & React.RefAttributes<HTMLDivElement>>;
|
|
32
|
+
|
|
33
|
+
interface FieldProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'id'> {
|
|
34
|
+
label: React.ReactNode;
|
|
35
|
+
helper?: React.ReactNode;
|
|
36
|
+
error?: React.ReactNode;
|
|
37
|
+
note?: React.ReactNode;
|
|
38
|
+
id?: string;
|
|
39
|
+
}
|
|
40
|
+
declare const Field: React.ForwardRefExoticComponent<FieldProps & React.RefAttributes<HTMLDivElement>>;
|
|
41
|
+
|
|
42
|
+
interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
43
|
+
prefilled?: boolean;
|
|
44
|
+
}
|
|
45
|
+
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
46
|
+
|
|
47
|
+
interface SelectOption {
|
|
48
|
+
value: string;
|
|
49
|
+
label: React.ReactNode;
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
}
|
|
52
|
+
interface SelectProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'defaultValue' | 'onChange' | 'dir'> {
|
|
53
|
+
options: SelectOption[];
|
|
54
|
+
value?: string;
|
|
55
|
+
defaultValue?: string;
|
|
56
|
+
onValueChange?: (value: string) => void;
|
|
57
|
+
placeholder?: React.ReactNode;
|
|
58
|
+
name?: string;
|
|
59
|
+
required?: boolean;
|
|
60
|
+
open?: boolean;
|
|
61
|
+
defaultOpen?: boolean;
|
|
62
|
+
onOpenChange?: (open: boolean) => void;
|
|
63
|
+
contentClassName?: string;
|
|
64
|
+
}
|
|
65
|
+
declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLButtonElement>>;
|
|
66
|
+
|
|
67
|
+
export { Badge, type BadgeProps, Banner, type BannerProps, Button, type ButtonProps, Field, type FieldProps, Input, type InputProps, Select, type SelectOption, type SelectProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -14,4 +14,54 @@ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, But
|
|
|
14
14
|
}
|
|
15
15
|
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
declare const badgeVariants: (props?: ({
|
|
18
|
+
status?: "success" | "info" | "caution" | "error" | "neutral" | null | undefined;
|
|
19
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
20
|
+
interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement>, VariantProps<typeof badgeVariants> {
|
|
21
|
+
}
|
|
22
|
+
declare const Badge: React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<HTMLSpanElement>>;
|
|
23
|
+
|
|
24
|
+
declare const bannerVariants: (props?: ({
|
|
25
|
+
status?: "success" | "info" | "caution" | "error" | null | undefined;
|
|
26
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
27
|
+
interface BannerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'>, VariantProps<typeof bannerVariants> {
|
|
28
|
+
title?: React.ReactNode;
|
|
29
|
+
icon?: React.ReactNode | null;
|
|
30
|
+
}
|
|
31
|
+
declare const Banner: React.ForwardRefExoticComponent<BannerProps & React.RefAttributes<HTMLDivElement>>;
|
|
32
|
+
|
|
33
|
+
interface FieldProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'id'> {
|
|
34
|
+
label: React.ReactNode;
|
|
35
|
+
helper?: React.ReactNode;
|
|
36
|
+
error?: React.ReactNode;
|
|
37
|
+
note?: React.ReactNode;
|
|
38
|
+
id?: string;
|
|
39
|
+
}
|
|
40
|
+
declare const Field: React.ForwardRefExoticComponent<FieldProps & React.RefAttributes<HTMLDivElement>>;
|
|
41
|
+
|
|
42
|
+
interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
43
|
+
prefilled?: boolean;
|
|
44
|
+
}
|
|
45
|
+
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
46
|
+
|
|
47
|
+
interface SelectOption {
|
|
48
|
+
value: string;
|
|
49
|
+
label: React.ReactNode;
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
}
|
|
52
|
+
interface SelectProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'value' | 'defaultValue' | 'onChange' | 'dir'> {
|
|
53
|
+
options: SelectOption[];
|
|
54
|
+
value?: string;
|
|
55
|
+
defaultValue?: string;
|
|
56
|
+
onValueChange?: (value: string) => void;
|
|
57
|
+
placeholder?: React.ReactNode;
|
|
58
|
+
name?: string;
|
|
59
|
+
required?: boolean;
|
|
60
|
+
open?: boolean;
|
|
61
|
+
defaultOpen?: boolean;
|
|
62
|
+
onOpenChange?: (open: boolean) => void;
|
|
63
|
+
contentClassName?: string;
|
|
64
|
+
}
|
|
65
|
+
declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLButtonElement>>;
|
|
66
|
+
|
|
67
|
+
export { Badge, type BadgeProps, Banner, type BannerProps, Button, type ButtonProps, Field, type FieldProps, Input, type InputProps, Select, type SelectOption, type SelectProps };
|
package/dist/index.js
CHANGED
|
@@ -166,6 +166,278 @@ var Button = React.forwardRef(
|
|
|
166
166
|
}
|
|
167
167
|
);
|
|
168
168
|
Button.displayName = "Button";
|
|
169
|
+
|
|
170
|
+
// src/components/badge/badge.tsx
|
|
171
|
+
import * as React2 from "react";
|
|
172
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
173
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
174
|
+
var badgeVariants = cva2(
|
|
175
|
+
"type-label-strong inline-flex h-6 shrink-0 items-center gap-spacing-xs whitespace-nowrap rounded-radius-full px-spacing-md",
|
|
176
|
+
{
|
|
177
|
+
variants: {
|
|
178
|
+
status: {
|
|
179
|
+
success: "bg-status-success-fill text-status-success-text",
|
|
180
|
+
info: "bg-status-info-fill text-status-info-text",
|
|
181
|
+
caution: "bg-status-caution-fill text-status-caution-text",
|
|
182
|
+
error: "bg-status-error-fill text-status-error-text",
|
|
183
|
+
neutral: "bg-status-neutral-fill text-status-neutral-text"
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
defaultVariants: {
|
|
187
|
+
status: "neutral"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
);
|
|
191
|
+
var Badge = React2.forwardRef(({ className, status, ...props }, ref) => /* @__PURE__ */ jsx2("span", { ref, className: cn(badgeVariants({ status }), className), ...props }));
|
|
192
|
+
Badge.displayName = "Badge";
|
|
193
|
+
|
|
194
|
+
// src/components/banner/banner.tsx
|
|
195
|
+
import * as React3 from "react";
|
|
196
|
+
import { cva as cva3 } from "class-variance-authority";
|
|
197
|
+
import { AlertCircle, AlertTriangle, CheckCircle2, Info } from "lucide-react";
|
|
198
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
199
|
+
var bannerVariants = cva3(
|
|
200
|
+
"type-body flex items-start gap-spacing-sm rounded-radius-lg border px-spacing-lg py-spacing-md",
|
|
201
|
+
{
|
|
202
|
+
variants: {
|
|
203
|
+
status: {
|
|
204
|
+
info: "border-status-info-border bg-status-info-fill text-status-info-text",
|
|
205
|
+
success: "border-status-success-border bg-status-success-fill text-status-success-text",
|
|
206
|
+
caution: "border-status-caution-border bg-status-caution-fill text-status-caution-text",
|
|
207
|
+
error: "border-status-error-border bg-status-error-fill text-status-error-text"
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
defaultVariants: {
|
|
211
|
+
status: "info"
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
);
|
|
215
|
+
var icons = {
|
|
216
|
+
info: Info,
|
|
217
|
+
success: CheckCircle2,
|
|
218
|
+
caution: AlertTriangle,
|
|
219
|
+
error: AlertCircle
|
|
220
|
+
};
|
|
221
|
+
var iconColour = {
|
|
222
|
+
info: "text-status-info-text",
|
|
223
|
+
success: "text-status-success-text",
|
|
224
|
+
caution: "text-status-caution-icon",
|
|
225
|
+
error: "text-status-error-text"
|
|
226
|
+
};
|
|
227
|
+
var Banner = React3.forwardRef(
|
|
228
|
+
({ className, status, title, icon, children, role = "status", ...props }, ref) => {
|
|
229
|
+
const resolved = status ?? "info";
|
|
230
|
+
const Icon2 = icons[resolved];
|
|
231
|
+
return /* @__PURE__ */ jsxs2("div", { ref, role, className: cn(bannerVariants({ status: resolved }), className), ...props, children: [
|
|
232
|
+
icon === null ? null : /* @__PURE__ */ jsx3("span", { "aria-hidden": "true", className: cn("mt-0.5 flex size-5 shrink-0 items-center", iconColour[resolved]), children: icon ?? /* @__PURE__ */ jsx3(Icon2, { className: "size-5", strokeWidth: 2 }) }),
|
|
233
|
+
/* @__PURE__ */ jsxs2("p", { className: "min-w-0", children: [
|
|
234
|
+
title ? /* @__PURE__ */ jsx3("strong", { className: "type-body-strong", children: title }) : null,
|
|
235
|
+
title && children ? " " : null,
|
|
236
|
+
children
|
|
237
|
+
] })
|
|
238
|
+
] });
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
Banner.displayName = "Banner";
|
|
242
|
+
|
|
243
|
+
// src/components/field/field.tsx
|
|
244
|
+
import * as React5 from "react";
|
|
245
|
+
|
|
246
|
+
// src/components/field/field-context.ts
|
|
247
|
+
import * as React4 from "react";
|
|
248
|
+
var FieldContext = React4.createContext(null);
|
|
249
|
+
|
|
250
|
+
// src/components/field/field.tsx
|
|
251
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
252
|
+
var Field = React5.forwardRef(
|
|
253
|
+
({ className, label, helper, error, note, id, children, ...props }, ref) => {
|
|
254
|
+
const generatedId = React5.useId();
|
|
255
|
+
const inputId = id ?? generatedId;
|
|
256
|
+
const messageId = `${inputId}-message`;
|
|
257
|
+
const message = error ?? note ?? helper;
|
|
258
|
+
const context = React5.useMemo(
|
|
259
|
+
() => ({
|
|
260
|
+
id: inputId,
|
|
261
|
+
describedBy: message ? messageId : void 0,
|
|
262
|
+
invalid: Boolean(error),
|
|
263
|
+
prefilled: !error && Boolean(note)
|
|
264
|
+
}),
|
|
265
|
+
[inputId, messageId, message, error, note]
|
|
266
|
+
);
|
|
267
|
+
return /* @__PURE__ */ jsxs3("div", { ref, className: cn("flex flex-col gap-1.5", className), ...props, children: [
|
|
268
|
+
/* @__PURE__ */ jsx4("label", { htmlFor: inputId, className: "type-label text-text-primary", children: label }),
|
|
269
|
+
/* @__PURE__ */ jsx4(FieldContext.Provider, { value: context, children }),
|
|
270
|
+
message ? /* @__PURE__ */ jsx4(
|
|
271
|
+
"p",
|
|
272
|
+
{
|
|
273
|
+
id: messageId,
|
|
274
|
+
className: cn(
|
|
275
|
+
"type-label",
|
|
276
|
+
error ? "text-status-error-strong" : note ? "text-status-info-text" : "text-text-muted"
|
|
277
|
+
),
|
|
278
|
+
children: message
|
|
279
|
+
}
|
|
280
|
+
) : null
|
|
281
|
+
] });
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
Field.displayName = "Field";
|
|
285
|
+
|
|
286
|
+
// src/components/input/input.tsx
|
|
287
|
+
import * as React6 from "react";
|
|
288
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
289
|
+
var inputClasses = [
|
|
290
|
+
"type-body h-12 w-full min-w-0 rounded-radius-md border border-border-strong bg-bg-surface px-spacing-lg",
|
|
291
|
+
"text-text-primary placeholder:text-text-muted transition-colors",
|
|
292
|
+
"hover:border-border-control",
|
|
293
|
+
"focus-visible:border-border-focus focus-visible:shadow-elevation-focus focus-visible:outline-none",
|
|
294
|
+
"focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-border-focus",
|
|
295
|
+
"data-[prefilled=true]:border-status-info-border",
|
|
296
|
+
"aria-[invalid=true]:border-status-error-border aria-[invalid=true]:ring-1 aria-[invalid=true]:ring-inset aria-[invalid=true]:ring-status-error-border",
|
|
297
|
+
"disabled:cursor-not-allowed disabled:border-border-default disabled:bg-bg-sunken disabled:text-text-muted"
|
|
298
|
+
];
|
|
299
|
+
var Input = React6.forwardRef(
|
|
300
|
+
({ className, prefilled, id, "aria-describedby": describedBy, "aria-invalid": invalid, ...props }, ref) => {
|
|
301
|
+
const field = React6.useContext(FieldContext);
|
|
302
|
+
const describedByIds = [field?.describedBy, describedBy].filter(Boolean).join(" ") || void 0;
|
|
303
|
+
const isInvalid = invalid ?? (field?.invalid ? true : void 0);
|
|
304
|
+
const isPrefilled = prefilled ?? field?.prefilled ?? false;
|
|
305
|
+
return /* @__PURE__ */ jsx5(
|
|
306
|
+
"input",
|
|
307
|
+
{
|
|
308
|
+
ref,
|
|
309
|
+
id: id ?? field?.id,
|
|
310
|
+
"aria-describedby": describedByIds,
|
|
311
|
+
"aria-invalid": isInvalid,
|
|
312
|
+
"data-prefilled": isPrefilled || void 0,
|
|
313
|
+
className: cn(inputClasses, className),
|
|
314
|
+
...props
|
|
315
|
+
}
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
);
|
|
319
|
+
Input.displayName = "Input";
|
|
320
|
+
|
|
321
|
+
// src/components/select/select.tsx
|
|
322
|
+
import * as React7 from "react";
|
|
323
|
+
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
324
|
+
import { Check, ChevronDown, ChevronUp } from "lucide-react";
|
|
325
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
326
|
+
var EMPTY_VALUE = "__af-select-empty__";
|
|
327
|
+
var selectTriggerClasses = [
|
|
328
|
+
"group type-body flex h-12 w-full min-w-0 items-center justify-between gap-spacing-sm rounded-radius-md border border-border-strong bg-bg-surface px-spacing-lg text-left",
|
|
329
|
+
"text-text-primary transition-colors data-[placeholder]:text-text-muted",
|
|
330
|
+
"hover:border-border-control",
|
|
331
|
+
"focus-visible:border-border-focus focus-visible:shadow-elevation-focus focus-visible:outline-none",
|
|
332
|
+
"focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-border-focus",
|
|
333
|
+
"data-[state=open]:border-border-focus data-[state=open]:shadow-elevation-focus",
|
|
334
|
+
"data-[state=open]:ring-1 data-[state=open]:ring-inset data-[state=open]:ring-border-focus",
|
|
335
|
+
"aria-[invalid=true]:border-status-error-border aria-[invalid=true]:ring-1 aria-[invalid=true]:ring-inset aria-[invalid=true]:ring-status-error-border",
|
|
336
|
+
"disabled:cursor-not-allowed disabled:border-border-default disabled:bg-bg-sunken disabled:text-text-muted"
|
|
337
|
+
];
|
|
338
|
+
var selectContentClasses = "relative z-50 max-h-80 overflow-hidden rounded-radius-lg border border-border-default bg-bg-surface shadow-elevation-floating";
|
|
339
|
+
var selectItemClasses = [
|
|
340
|
+
"type-body relative flex h-11 cursor-pointer select-none items-center gap-spacing-sm rounded-radius-sm px-spacing-md text-text-primary outline-none",
|
|
341
|
+
"data-[highlighted]:data-[state=unchecked]:bg-bg-hover",
|
|
342
|
+
"data-[state=checked]:type-body-strong data-[state=checked]:bg-bg-selected data-[state=checked]:text-text-on-selected",
|
|
343
|
+
"data-[disabled]:cursor-not-allowed data-[disabled]:text-text-muted"
|
|
344
|
+
];
|
|
345
|
+
var Select = React7.forwardRef(
|
|
346
|
+
({
|
|
347
|
+
options,
|
|
348
|
+
value,
|
|
349
|
+
defaultValue,
|
|
350
|
+
onValueChange,
|
|
351
|
+
placeholder,
|
|
352
|
+
name,
|
|
353
|
+
required,
|
|
354
|
+
disabled,
|
|
355
|
+
open,
|
|
356
|
+
defaultOpen,
|
|
357
|
+
onOpenChange,
|
|
358
|
+
className,
|
|
359
|
+
contentClassName,
|
|
360
|
+
id,
|
|
361
|
+
"aria-describedby": describedBy,
|
|
362
|
+
"aria-invalid": invalid,
|
|
363
|
+
...props
|
|
364
|
+
}, ref) => {
|
|
365
|
+
const field = React7.useContext(FieldContext);
|
|
366
|
+
const hasEmptyOption = options.some((option) => option.value === "");
|
|
367
|
+
const toInternal = (next) => next === "" && hasEmptyOption ? EMPTY_VALUE : next;
|
|
368
|
+
const describedByIds = [field?.describedBy, describedBy].filter(Boolean).join(" ") || void 0;
|
|
369
|
+
const isInvalid = invalid ?? (field?.invalid ? true : void 0);
|
|
370
|
+
return /* @__PURE__ */ jsxs4(
|
|
371
|
+
SelectPrimitive.Root,
|
|
372
|
+
{
|
|
373
|
+
value: toInternal(value),
|
|
374
|
+
defaultValue: toInternal(defaultValue),
|
|
375
|
+
onValueChange: (next) => onValueChange?.(next === EMPTY_VALUE ? "" : next),
|
|
376
|
+
name,
|
|
377
|
+
required,
|
|
378
|
+
disabled,
|
|
379
|
+
open,
|
|
380
|
+
defaultOpen,
|
|
381
|
+
onOpenChange,
|
|
382
|
+
children: [
|
|
383
|
+
/* @__PURE__ */ jsxs4(
|
|
384
|
+
SelectPrimitive.Trigger,
|
|
385
|
+
{
|
|
386
|
+
ref,
|
|
387
|
+
id: id ?? field?.id,
|
|
388
|
+
"aria-describedby": describedByIds,
|
|
389
|
+
"aria-invalid": isInvalid,
|
|
390
|
+
className: cn(selectTriggerClasses, className),
|
|
391
|
+
...props,
|
|
392
|
+
children: [
|
|
393
|
+
/* @__PURE__ */ jsx6("span", { className: "min-w-0 flex-1 truncate", children: /* @__PURE__ */ jsx6(SelectPrimitive.Value, { placeholder }) }),
|
|
394
|
+
/* @__PURE__ */ jsx6(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx6(
|
|
395
|
+
ChevronDown,
|
|
396
|
+
{
|
|
397
|
+
"aria-hidden": "true",
|
|
398
|
+
className: "size-5 shrink-0 text-text-primary transition-transform group-data-[state=open]:rotate-180 group-disabled:text-text-muted"
|
|
399
|
+
}
|
|
400
|
+
) })
|
|
401
|
+
]
|
|
402
|
+
}
|
|
403
|
+
),
|
|
404
|
+
/* @__PURE__ */ jsx6(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs4(
|
|
405
|
+
SelectPrimitive.Content,
|
|
406
|
+
{
|
|
407
|
+
position: "popper",
|
|
408
|
+
sideOffset: 4,
|
|
409
|
+
className: cn(selectContentClasses, contentClassName),
|
|
410
|
+
style: { minWidth: "var(--radix-select-trigger-width)" },
|
|
411
|
+
children: [
|
|
412
|
+
/* @__PURE__ */ jsx6(SelectPrimitive.ScrollUpButton, { className: "flex h-6 items-center justify-center text-text-muted", children: /* @__PURE__ */ jsx6(ChevronUp, { "aria-hidden": "true", className: "size-4" }) }),
|
|
413
|
+
/* @__PURE__ */ jsx6(SelectPrimitive.Viewport, { className: "flex flex-col p-spacing-sm", children: options.map((option) => /* @__PURE__ */ jsxs4(
|
|
414
|
+
SelectPrimitive.Item,
|
|
415
|
+
{
|
|
416
|
+
value: option.value === "" ? EMPTY_VALUE : option.value,
|
|
417
|
+
disabled: option.disabled,
|
|
418
|
+
className: cn(selectItemClasses),
|
|
419
|
+
children: [
|
|
420
|
+
/* @__PURE__ */ jsx6(SelectPrimitive.ItemText, { asChild: true, children: /* @__PURE__ */ jsx6("span", { className: "min-w-0 flex-1 truncate", children: option.label }) }),
|
|
421
|
+
/* @__PURE__ */ jsx6(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx6(Check, { "aria-hidden": "true", className: "size-5 shrink-0 text-text-on-selected" }) })
|
|
422
|
+
]
|
|
423
|
+
},
|
|
424
|
+
option.value === "" ? EMPTY_VALUE : option.value
|
|
425
|
+
)) }),
|
|
426
|
+
/* @__PURE__ */ jsx6(SelectPrimitive.ScrollDownButton, { className: "flex h-6 items-center justify-center text-text-muted", children: /* @__PURE__ */ jsx6(ChevronDown, { "aria-hidden": "true", className: "size-4" }) })
|
|
427
|
+
]
|
|
428
|
+
}
|
|
429
|
+
) })
|
|
430
|
+
]
|
|
431
|
+
}
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
);
|
|
435
|
+
Select.displayName = "Select";
|
|
169
436
|
export {
|
|
170
|
-
|
|
437
|
+
Badge,
|
|
438
|
+
Banner,
|
|
439
|
+
Button,
|
|
440
|
+
Field,
|
|
441
|
+
Input,
|
|
442
|
+
Select
|
|
171
443
|
};
|
package/dist/utils.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -69,6 +69,81 @@ var buttonVariants = _classvarianceauthority.cva.call(void 0,
|
|
|
69
69
|
}
|
|
70
70
|
);
|
|
71
71
|
|
|
72
|
+
// src/components/badge/badge.tsx
|
|
73
|
+
var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react);
|
|
74
|
+
|
|
75
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
76
|
+
var badgeVariants = _classvarianceauthority.cva.call(void 0,
|
|
77
|
+
"type-label-strong inline-flex h-6 shrink-0 items-center gap-spacing-xs whitespace-nowrap rounded-radius-full px-spacing-md",
|
|
78
|
+
{
|
|
79
|
+
variants: {
|
|
80
|
+
status: {
|
|
81
|
+
success: "bg-status-success-fill text-status-success-text",
|
|
82
|
+
info: "bg-status-info-fill text-status-info-text",
|
|
83
|
+
caution: "bg-status-caution-fill text-status-caution-text",
|
|
84
|
+
error: "bg-status-error-fill text-status-error-text",
|
|
85
|
+
neutral: "bg-status-neutral-fill text-status-neutral-text"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
defaultVariants: {
|
|
89
|
+
status: "neutral"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
var Badge = React.forwardRef(({ className, status, ...props }, ref) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { ref, className: cn(badgeVariants({ status }), className), ...props }));
|
|
94
|
+
Badge.displayName = "Badge";
|
|
95
|
+
|
|
96
|
+
// src/components/banner/banner.tsx
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
var _lucidereact = require('lucide-react');
|
|
100
|
+
|
|
101
|
+
var bannerVariants = _classvarianceauthority.cva.call(void 0,
|
|
102
|
+
"type-body flex items-start gap-spacing-sm rounded-radius-lg border px-spacing-lg py-spacing-md",
|
|
103
|
+
{
|
|
104
|
+
variants: {
|
|
105
|
+
status: {
|
|
106
|
+
info: "border-status-info-border bg-status-info-fill text-status-info-text",
|
|
107
|
+
success: "border-status-success-border bg-status-success-fill text-status-success-text",
|
|
108
|
+
caution: "border-status-caution-border bg-status-caution-fill text-status-caution-text",
|
|
109
|
+
error: "border-status-error-border bg-status-error-fill text-status-error-text"
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
defaultVariants: {
|
|
113
|
+
status: "info"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
var icons = {
|
|
118
|
+
info: _lucidereact.Info,
|
|
119
|
+
success: _lucidereact.CheckCircle2,
|
|
120
|
+
caution: _lucidereact.AlertTriangle,
|
|
121
|
+
error: _lucidereact.AlertCircle
|
|
122
|
+
};
|
|
123
|
+
var iconColour = {
|
|
124
|
+
info: "text-status-info-text",
|
|
125
|
+
success: "text-status-success-text",
|
|
126
|
+
caution: "text-status-caution-icon",
|
|
127
|
+
error: "text-status-error-text"
|
|
128
|
+
};
|
|
129
|
+
var Banner = React2.forwardRef(
|
|
130
|
+
({ className, status, title, icon, children, role = "status", ...props }, ref) => {
|
|
131
|
+
const resolved = _nullishCoalesce(status, () => ( "info"));
|
|
132
|
+
const Icon = icons[resolved];
|
|
133
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { ref, role, className: cn(bannerVariants({ status: resolved }), className), ...props, children: [
|
|
134
|
+
icon === null ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { "aria-hidden": "true", className: cn("mt-0.5 flex size-5 shrink-0 items-center", iconColour[resolved]), children: _nullishCoalesce(icon, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Icon, { className: "size-5", strokeWidth: 2 }))) }),
|
|
135
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "min-w-0", children: [
|
|
136
|
+
title ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "strong", { className: "type-body-strong", children: title }) : null,
|
|
137
|
+
title && children ? " " : null,
|
|
138
|
+
children
|
|
139
|
+
] })
|
|
140
|
+
] });
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
Banner.displayName = "Banner";
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
72
147
|
|
|
73
148
|
|
|
74
|
-
exports.buttonVariants = buttonVariants; exports.cn = cn;
|
|
149
|
+
exports.badgeVariants = badgeVariants; exports.bannerVariants = bannerVariants; exports.buttonVariants = buttonVariants; exports.cn = cn;
|
package/dist/utils.d.cts
CHANGED
|
@@ -10,4 +10,12 @@ declare const buttonVariants: (props?: ({
|
|
|
10
10
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
11
11
|
type ButtonVariantProps = VariantProps<typeof buttonVariants>;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
declare const badgeVariants: (props?: ({
|
|
14
|
+
status?: "success" | "info" | "caution" | "error" | "neutral" | null | undefined;
|
|
15
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
16
|
+
|
|
17
|
+
declare const bannerVariants: (props?: ({
|
|
18
|
+
status?: "success" | "info" | "caution" | "error" | null | undefined;
|
|
19
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
20
|
+
|
|
21
|
+
export { type ButtonVariantProps, badgeVariants, bannerVariants, buttonVariants, cn };
|
package/dist/utils.d.ts
CHANGED
|
@@ -10,4 +10,12 @@ declare const buttonVariants: (props?: ({
|
|
|
10
10
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
11
11
|
type ButtonVariantProps = VariantProps<typeof buttonVariants>;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
declare const badgeVariants: (props?: ({
|
|
14
|
+
status?: "success" | "info" | "caution" | "error" | "neutral" | null | undefined;
|
|
15
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
16
|
+
|
|
17
|
+
declare const bannerVariants: (props?: ({
|
|
18
|
+
status?: "success" | "info" | "caution" | "error" | null | undefined;
|
|
19
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
20
|
+
|
|
21
|
+
export { type ButtonVariantProps, badgeVariants, bannerVariants, buttonVariants, cn };
|
package/dist/utils.js
CHANGED
|
@@ -68,7 +68,82 @@ var buttonVariants = cva(
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
);
|
|
71
|
+
|
|
72
|
+
// src/components/badge/badge.tsx
|
|
73
|
+
import * as React from "react";
|
|
74
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
75
|
+
import { jsx } from "react/jsx-runtime";
|
|
76
|
+
var badgeVariants = cva2(
|
|
77
|
+
"type-label-strong inline-flex h-6 shrink-0 items-center gap-spacing-xs whitespace-nowrap rounded-radius-full px-spacing-md",
|
|
78
|
+
{
|
|
79
|
+
variants: {
|
|
80
|
+
status: {
|
|
81
|
+
success: "bg-status-success-fill text-status-success-text",
|
|
82
|
+
info: "bg-status-info-fill text-status-info-text",
|
|
83
|
+
caution: "bg-status-caution-fill text-status-caution-text",
|
|
84
|
+
error: "bg-status-error-fill text-status-error-text",
|
|
85
|
+
neutral: "bg-status-neutral-fill text-status-neutral-text"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
defaultVariants: {
|
|
89
|
+
status: "neutral"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
var Badge = React.forwardRef(({ className, status, ...props }, ref) => /* @__PURE__ */ jsx("span", { ref, className: cn(badgeVariants({ status }), className), ...props }));
|
|
94
|
+
Badge.displayName = "Badge";
|
|
95
|
+
|
|
96
|
+
// src/components/banner/banner.tsx
|
|
97
|
+
import * as React2 from "react";
|
|
98
|
+
import { cva as cva3 } from "class-variance-authority";
|
|
99
|
+
import { AlertCircle, AlertTriangle, CheckCircle2, Info } from "lucide-react";
|
|
100
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
101
|
+
var bannerVariants = cva3(
|
|
102
|
+
"type-body flex items-start gap-spacing-sm rounded-radius-lg border px-spacing-lg py-spacing-md",
|
|
103
|
+
{
|
|
104
|
+
variants: {
|
|
105
|
+
status: {
|
|
106
|
+
info: "border-status-info-border bg-status-info-fill text-status-info-text",
|
|
107
|
+
success: "border-status-success-border bg-status-success-fill text-status-success-text",
|
|
108
|
+
caution: "border-status-caution-border bg-status-caution-fill text-status-caution-text",
|
|
109
|
+
error: "border-status-error-border bg-status-error-fill text-status-error-text"
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
defaultVariants: {
|
|
113
|
+
status: "info"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
var icons = {
|
|
118
|
+
info: Info,
|
|
119
|
+
success: CheckCircle2,
|
|
120
|
+
caution: AlertTriangle,
|
|
121
|
+
error: AlertCircle
|
|
122
|
+
};
|
|
123
|
+
var iconColour = {
|
|
124
|
+
info: "text-status-info-text",
|
|
125
|
+
success: "text-status-success-text",
|
|
126
|
+
caution: "text-status-caution-icon",
|
|
127
|
+
error: "text-status-error-text"
|
|
128
|
+
};
|
|
129
|
+
var Banner = React2.forwardRef(
|
|
130
|
+
({ className, status, title, icon, children, role = "status", ...props }, ref) => {
|
|
131
|
+
const resolved = status ?? "info";
|
|
132
|
+
const Icon = icons[resolved];
|
|
133
|
+
return /* @__PURE__ */ jsxs("div", { ref, role, className: cn(bannerVariants({ status: resolved }), className), ...props, children: [
|
|
134
|
+
icon === null ? null : /* @__PURE__ */ jsx2("span", { "aria-hidden": "true", className: cn("mt-0.5 flex size-5 shrink-0 items-center", iconColour[resolved]), children: icon ?? /* @__PURE__ */ jsx2(Icon, { className: "size-5", strokeWidth: 2 }) }),
|
|
135
|
+
/* @__PURE__ */ jsxs("p", { className: "min-w-0", children: [
|
|
136
|
+
title ? /* @__PURE__ */ jsx2("strong", { className: "type-body-strong", children: title }) : null,
|
|
137
|
+
title && children ? " " : null,
|
|
138
|
+
children
|
|
139
|
+
] })
|
|
140
|
+
] });
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
Banner.displayName = "Banner";
|
|
71
144
|
export {
|
|
145
|
+
badgeVariants,
|
|
146
|
+
bannerVariants,
|
|
72
147
|
buttonVariants,
|
|
73
148
|
cn
|
|
74
149
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travelallfly/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "AllFly design system: tokens, Tailwind preset and shared React components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -75,11 +75,13 @@
|
|
|
75
75
|
"test-consumers": "node scripts/test-consumers.mjs"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
+
"lucide-react": ">=0.292.0 <1",
|
|
78
79
|
"react": ">=18",
|
|
79
80
|
"react-dom": ">=18",
|
|
80
81
|
"tailwindcss": ">=3.4 <4"
|
|
81
82
|
},
|
|
82
83
|
"dependencies": {
|
|
84
|
+
"@radix-ui/react-select": "^2.4.1",
|
|
83
85
|
"@radix-ui/react-slot": "^1.2.0",
|
|
84
86
|
"class-variance-authority": "^0.7.1",
|
|
85
87
|
"clsx": "^2.1.1",
|
|
@@ -103,6 +105,7 @@
|
|
|
103
105
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
104
106
|
"globals": "^17.14.0",
|
|
105
107
|
"jsdom": "^26.0.0",
|
|
108
|
+
"lucide-react": "^0.474.0",
|
|
106
109
|
"postcss": "^8.4.49",
|
|
107
110
|
"react": "^19.0.1",
|
|
108
111
|
"react-dom": "^19.0.1",
|