@enablo/swirlcn-ui 0.0.0-stage → 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.
Files changed (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -2
  3. package/dist/chunk-3DJWDNQL.js +77 -0
  4. package/dist/chunk-7XUCETA6.js +447 -0
  5. package/dist/chunk-KZESIYUN.js +18 -0
  6. package/dist/flip.d.ts +98 -0
  7. package/dist/flip.js +158 -0
  8. package/dist/fonts/Inter-italic.var.woff2 +0 -0
  9. package/dist/fonts/Inter.var.woff2 +0 -0
  10. package/dist/fonts/OFL.txt +96 -0
  11. package/dist/index.d.ts +2459 -0
  12. package/dist/index.js +8439 -0
  13. package/dist/server.d.ts +144 -0
  14. package/dist/server.js +88 -0
  15. package/dist/spacing-BQaEPbUv.d.ts +59 -0
  16. package/dist/theme.css +146 -0
  17. package/package.json +84 -3
  18. package/src/components/accordion.tsx +102 -0
  19. package/src/components/action-list.tsx +294 -0
  20. package/src/components/alert-dialog.tsx +155 -0
  21. package/src/components/autocomplete.tsx +313 -0
  22. package/src/components/avatar.tsx +258 -0
  23. package/src/components/badge.tsx +100 -0
  24. package/src/components/banner.tsx +112 -0
  25. package/src/components/button-group.tsx +87 -0
  26. package/src/components/button.tsx +362 -0
  27. package/src/components/card.tsx +186 -0
  28. package/src/components/carousel.tsx +245 -0
  29. package/src/components/checkbox.tsx +125 -0
  30. package/src/components/chip.tsx +153 -0
  31. package/src/components/color-input.tsx +98 -0
  32. package/src/components/data-cell.tsx +230 -0
  33. package/src/components/date-input.tsx +223 -0
  34. package/src/components/date-picker.tsx +276 -0
  35. package/src/components/description-list.tsx +97 -0
  36. package/src/components/dialog.tsx +405 -0
  37. package/src/components/empty-state.tsx +63 -0
  38. package/src/components/file-chip.tsx +206 -0
  39. package/src/components/file-uploader.tsx +148 -0
  40. package/src/components/flip-app-header.tsx +104 -0
  41. package/src/components/flip-brand.tsx +77 -0
  42. package/src/components/flip-theme.tsx +95 -0
  43. package/src/components/form-control.tsx +397 -0
  44. package/src/components/form-group.tsx +26 -0
  45. package/src/components/heading.tsx +70 -0
  46. package/src/components/icon.tsx +119 -0
  47. package/src/components/image-grid.tsx +285 -0
  48. package/src/components/inline-notification.tsx +167 -0
  49. package/src/components/inline-status.tsx +100 -0
  50. package/src/components/input.tsx +390 -0
  51. package/src/components/label.tsx +28 -0
  52. package/src/components/lightbox.tsx +314 -0
  53. package/src/components/link.tsx +46 -0
  54. package/src/components/list.tsx +40 -0
  55. package/src/components/menu.tsx +530 -0
  56. package/src/components/option-list.tsx +582 -0
  57. package/src/components/pagination.tsx +336 -0
  58. package/src/components/popover.tsx +194 -0
  59. package/src/components/progress.tsx +158 -0
  60. package/src/components/radio-group.tsx +136 -0
  61. package/src/components/resource-list.tsx +686 -0
  62. package/src/components/search.tsx +127 -0
  63. package/src/components/select.tsx +456 -0
  64. package/src/components/separator.tsx +93 -0
  65. package/src/components/skeleton-box.tsx +63 -0
  66. package/src/components/skeleton-text.tsx +66 -0
  67. package/src/components/spinner.tsx +83 -0
  68. package/src/components/stack.tsx +86 -0
  69. package/src/components/status-indicator.tsx +31 -0
  70. package/src/components/switch.tsx +90 -0
  71. package/src/components/table.tsx +242 -0
  72. package/src/components/tabs.tsx +147 -0
  73. package/src/components/tag.tsx +169 -0
  74. package/src/components/text.tsx +126 -0
  75. package/src/components/textarea.tsx +130 -0
  76. package/src/components/theme-provider.tsx +115 -0
  77. package/src/components/thumbnail.tsx +250 -0
  78. package/src/components/time-input.tsx +123 -0
  79. package/src/components/toast.tsx +217 -0
  80. package/src/components/toggle-group.tsx +124 -0
  81. package/src/components/toolbar.tsx +105 -0
  82. package/src/components/tooltip.tsx +97 -0
  83. package/src/components/tree-navigation.tsx +194 -0
  84. package/src/components/tree-view.tsx +292 -0
  85. package/src/flip.ts +12 -0
  86. package/src/index.ts +317 -0
  87. package/src/lib/date-mask.ts +176 -0
  88. package/src/lib/field-context.ts +86 -0
  89. package/src/lib/flip-app-script.ts +38 -0
  90. package/src/lib/flip-host.ts +84 -0
  91. package/src/lib/flip-theme-css.ts +90 -0
  92. package/src/lib/focus.ts +18 -0
  93. package/src/lib/glyphs.ts +137 -0
  94. package/src/lib/spacing.ts +93 -0
  95. package/src/lib/theme-context.ts +27 -0
  96. package/src/lib/theme-script.ts +49 -0
  97. package/src/lib/use-mobile.ts +17 -0
  98. package/src/lib/utils.ts +28 -0
  99. package/src/server.ts +20 -0
  100. package/src/styles/fonts/Inter-italic.var.woff2 +0 -0
  101. package/src/styles/fonts/Inter.var.woff2 +0 -0
  102. package/src/styles/fonts/OFL.txt +96 -0
  103. package/src/styles/theme.css +146 -0
@@ -0,0 +1,136 @@
1
+ import { RadioGroup as RadioGroupPrimitive } from "radix-ui";
2
+ import { cn } from "../lib/utils";
3
+ import { Tooltip } from "./tooltip";
4
+
5
+ export interface RadioGroupProps
6
+ extends React.ComponentProps<typeof RadioGroupPrimitive.Root> {}
7
+
8
+ /** Swirl's radio group: its radios stacked 12px apart. */
9
+ export function RadioGroup({ className, ...props }: RadioGroupProps) {
10
+ return (
11
+ <RadioGroupPrimitive.Root className={cn("flex flex-col gap-3", className)} {...props} />
12
+ );
13
+ }
14
+
15
+ const HelpIcon = () => (
16
+ <svg viewBox="0 0 24 24" className="size-5" aria-hidden focusable={false}>
17
+ <path
18
+ d="M11.95 18C12.3 18 12.596 17.879 12.838 17.637C13.0793 17.3957 13.2 17.1 13.2 16.75C13.2 16.4 13.0793 16.1043 12.838 15.863C12.596 15.621 12.3 15.5 11.95 15.5C11.6 15.5 11.304 15.621 11.062 15.863C10.8207 16.1043 10.7 16.4 10.7 16.75C10.7 17.1 10.8207 17.3957 11.062 17.637C11.304 17.879 11.6 18 11.95 18ZM12.1 7.7C12.5667 7.7 12.9417 7.829 13.225 8.087C13.5083 8.34567 13.65 8.68333 13.65 9.1C13.65 9.38333 13.5543 9.67067 13.363 9.962C13.171 10.254 12.9 10.5583 12.55 10.875C12.05 11.3083 11.6833 11.725 11.45 12.125C11.2167 12.525 11.1 12.925 11.1 13.325C11.1 13.5583 11.1877 13.754 11.363 13.912C11.5377 14.0707 11.7417 14.15 11.975 14.15C12.2083 14.15 12.4167 14.0667 12.6 13.9C12.7833 13.7333 12.9 13.525 12.95 13.275C13 12.9917 13.1127 12.7293 13.288 12.488C13.4627 12.246 13.75 11.9333 14.15 11.55C14.6667 11.0667 15.0293 10.625 15.238 10.225C15.446 9.825 15.55 9.38333 15.55 8.9C15.55 8.05 15.2293 7.354 14.588 6.812C13.946 6.27067 13.1167 6 12.1 6C11.4 6 10.7793 6.13333 10.238 6.4C9.696 6.66667 9.275 7.075 8.975 7.625C8.85833 7.84167 8.81667 8.054 8.85 8.262C8.88333 8.47067 9 8.64167 9.2 8.775C9.41667 8.90833 9.65433 8.95 9.913 8.9C10.171 8.85 10.3833 8.70833 10.55 8.475C10.7333 8.225 10.9543 8.03333 11.213 7.9C11.471 7.76667 11.7667 7.7 12.1 7.7ZM12 22C10.6333 22 9.34167 21.7373 8.125 21.212C6.90833 20.6873 5.846 19.975 4.938 19.075C4.02933 18.175 3.31267 17.1167 2.788 15.9C2.26267 14.6833 2 13.3833 2 12C2 10.6167 2.26267 9.31667 2.788 8.1C3.31267 6.88333 4.02933 5.825 4.938 4.925C5.846 4.025 6.90833 3.31233 8.125 2.787C9.34167 2.26233 10.6333 2 12 2C13.4 2 14.7083 2.26233 15.925 2.787C17.1417 3.31233 18.2 4.025 19.1 4.925C20 5.825 20.7083 6.88333 21.225 8.1C21.7417 9.31667 22 10.6167 22 12C22 13.3833 21.7417 14.6833 21.225 15.9C20.7083 17.1167 20 18.175 19.1 19.075C18.2 19.975 17.1417 20.6873 15.925 21.212C14.7083 21.7373 13.4 22 12 22ZM12 20C14.2333 20 16.125 19.221 17.675 17.663C19.225 16.1043 20 14.2167 20 12C20 9.78333 19.225 7.89567 17.675 6.337C16.125 4.779 14.2333 4 12 4C9.81667 4 7.93733 4.779 6.362 6.337C4.78733 7.89567 4 9.78333 4 12C4 14.2167 4.78733 16.1043 6.362 17.663C7.93733 19.221 9.81667 20 12 20Z"
19
+ fill="currentColor"
20
+ />
21
+ </svg>
22
+ );
23
+
24
+ export interface RadioProps
25
+ extends React.ComponentProps<typeof RadioGroupPrimitive.Item> {
26
+ label?: React.ReactNode;
27
+ description?: React.ReactNode;
28
+ /** Help text in a tooltip on an icon beside the label. */
29
+ tooltip?: React.ReactNode;
30
+ /** `card` puts the radio and its text in a bordered, full-width box. */
31
+ variant?: "default" | "card";
32
+ /** Draw the radio in the critical colour. */
33
+ invalid?: boolean;
34
+ }
35
+
36
+ /**
37
+ * A single radio, drawn as Swirl draws it: a 2px ring that fills with the
38
+ * highlight colour and a centre dot when checked. Must sit inside a
39
+ * `RadioGroup`. With a `label` the whole row is a `<label>`, so clicking the
40
+ * text chooses the radio.
41
+ */
42
+ export function Radio({
43
+ className,
44
+ label,
45
+ description,
46
+ tooltip,
47
+ variant = "default",
48
+ invalid = false,
49
+ id,
50
+ ...props
51
+ }: RadioProps) {
52
+ const card = variant === "card";
53
+ const control = (
54
+ // Swirl's control: a 24px hit area (22px with the desktop layout) around
55
+ // the ring, which hover tints.
56
+ <span className="group/control relative inline-flex size-6 shrink-0 p-0.5 desktop:size-5.5">
57
+ <RadioGroupPrimitive.Item
58
+ id={id}
59
+ aria-invalid={invalid || undefined}
60
+ className={cn(
61
+ "peer flex size-full cursor-pointer items-center justify-center rounded-full",
62
+ "border-2 border-icon-default bg-transparent outline-none",
63
+ "group-hover/control:bg-neutral-hovered",
64
+ "data-[state=checked]:border-highlight data-[state=checked]:bg-highlight",
65
+ "group-hover/control:data-[state=checked]:border-interactive-primary-hovered group-hover/control:data-[state=checked]:bg-interactive-primary-hovered",
66
+ "aria-invalid:border-critical aria-invalid:data-[state=checked]:border-critical aria-invalid:data-[state=checked]:bg-critical",
67
+ "disabled:cursor-default disabled:border-disabled disabled:group-hover/control:bg-transparent",
68
+ "disabled:data-[state=checked]:border-disabled disabled:data-[state=checked]:bg-background",
69
+ "disabled:group-hover/control:data-[state=checked]:border-disabled disabled:group-hover/control:data-[state=checked]:bg-background",
70
+ // Swirl's focus ring: a 1px gap in the page colour, then 2px of focus.
71
+ // A card draws the ring around the whole card instead.
72
+ !card && "focus-visible:shadow-[0_0_0_1px_var(--color-background),0_0_0_3px_var(--color-focus)]",
73
+ className,
74
+ )}
75
+ {...props}
76
+ >
77
+ <RadioGroupPrimitive.Indicator className="flex size-full items-center justify-center">
78
+ <span
79
+ className={cn("size-2 rounded-full", props.disabled ? "bg-disabled" : "bg-background")}
80
+ />
81
+ </RadioGroupPrimitive.Indicator>
82
+ </RadioGroupPrimitive.Item>
83
+ </span>
84
+ );
85
+
86
+ if (!label && !description) return control;
87
+
88
+ return (
89
+ <label
90
+ className={cn(
91
+ "group/radio inline-flex cursor-pointer items-center leading-6 has-disabled:cursor-default",
92
+ card && [
93
+ "w-full rounded-sm border border-border bg-surface p-4",
94
+ "not-has-disabled:hover:bg-state-hovered not-has-disabled:active:bg-state-pressed",
95
+ "not-has-disabled:has-data-[state=checked]:border-highlight",
96
+ "not-has-disabled:has-aria-invalid:border-critical",
97
+ "has-focus-visible:shadow-[0_0_0_2px_var(--color-background),0_0_0_4px_var(--color-focus)]",
98
+ ],
99
+ )}
100
+ >
101
+ {control}
102
+ <span className="ml-2 inline-flex flex-col pt-0.5">
103
+ {label && (
104
+ <span
105
+ className={cn(
106
+ "flex items-center gap-2 font-medium text-foreground desktop:text-sm desktop:leading-5",
107
+ "group-has-disabled/radio:text-disabled",
108
+ )}
109
+ >
110
+ {label}
111
+ {tooltip && (
112
+ <Tooltip content={tooltip}>
113
+ <span
114
+ tabIndex={0}
115
+ className="inline-flex rounded-full text-icon-default outline-focus focus:not-focus-visible:outline-none"
116
+ >
117
+ <HelpIcon />
118
+ </span>
119
+ </Tooltip>
120
+ )}
121
+ </span>
122
+ )}
123
+ {description && (
124
+ <span
125
+ className={cn(
126
+ "text-subdued desktop:text-sm desktop:leading-5",
127
+ "group-has-disabled/radio:text-disabled",
128
+ )}
129
+ >
130
+ {description}
131
+ </span>
132
+ )}
133
+ </span>
134
+ </label>
135
+ );
136
+ }