@travelallfly/ui 0.4.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 CHANGED
@@ -35,7 +35,8 @@ __export(src_exports, {
35
35
  Banner: () => Banner,
36
36
  Button: () => Button,
37
37
  Field: () => Field,
38
- Input: () => Input
38
+ Input: () => Input,
39
+ Select: () => Select
39
40
  });
40
41
  module.exports = __toCommonJS(src_exports);
41
42
 
@@ -266,9 +267,9 @@ var iconColour = {
266
267
  var Banner = React3.forwardRef(
267
268
  ({ className, status, title, icon, children, role = "status", ...props }, ref) => {
268
269
  const resolved = status ?? "info";
269
- const Icon = icons[resolved];
270
+ const Icon2 = icons[resolved];
270
271
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { ref, role, className: cn(bannerVariants({ status: resolved }), className), ...props, children: [
271
- 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)(Icon, { className: "size-5", strokeWidth: 2 }) }),
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 }) }),
272
273
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: "min-w-0", children: [
273
274
  title ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { className: "type-body-strong", children: title }) : null,
274
275
  title && children ? " " : null,
@@ -356,11 +357,128 @@ var Input = React6.forwardRef(
356
357
  }
357
358
  );
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";
359
476
  // Annotate the CommonJS export names for ESM import in node:
360
477
  0 && (module.exports = {
361
478
  Badge,
362
479
  Banner,
363
480
  Button,
364
481
  Field,
365
- Input
482
+ Input,
483
+ Select
366
484
  });
package/dist/index.d.cts CHANGED
@@ -44,4 +44,24 @@ interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
44
44
  }
45
45
  declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
46
46
 
47
- export { Badge, type BadgeProps, Banner, type BannerProps, Button, type ButtonProps, Field, type FieldProps, Input, type InputProps };
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
@@ -44,4 +44,24 @@ interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
44
44
  }
45
45
  declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
46
46
 
47
- export { Badge, type BadgeProps, Banner, type BannerProps, Button, type ButtonProps, Field, type FieldProps, Input, type InputProps };
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
@@ -227,9 +227,9 @@ var iconColour = {
227
227
  var Banner = React3.forwardRef(
228
228
  ({ className, status, title, icon, children, role = "status", ...props }, ref) => {
229
229
  const resolved = status ?? "info";
230
- const Icon = icons[resolved];
230
+ const Icon2 = icons[resolved];
231
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(Icon, { className: "size-5", strokeWidth: 2 }) }),
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
233
  /* @__PURE__ */ jsxs2("p", { className: "min-w-0", children: [
234
234
  title ? /* @__PURE__ */ jsx3("strong", { className: "type-body-strong", children: title }) : null,
235
235
  title && children ? " " : null,
@@ -317,10 +317,127 @@ var Input = React6.forwardRef(
317
317
  }
318
318
  );
319
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";
320
436
  export {
321
437
  Badge,
322
438
  Banner,
323
439
  Button,
324
440
  Field,
325
- Input
441
+ Input,
442
+ Select
326
443
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travelallfly/ui",
3
- "version": "0.4.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",
@@ -81,6 +81,7 @@
81
81
  "tailwindcss": ">=3.4 <4"
82
82
  },
83
83
  "dependencies": {
84
+ "@radix-ui/react-select": "^2.4.1",
84
85
  "@radix-ui/react-slot": "^1.2.0",
85
86
  "class-variance-authority": "^0.7.1",
86
87
  "clsx": "^2.1.1",