@realmorg/ui 0.0.0-stage → 2.0.0-alpha.3

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 (66) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +44 -2
  3. package/components/accordion.html +139 -0
  4. package/components/alert-dialog.html +236 -0
  5. package/components/alert.html +83 -0
  6. package/components/aspect-ratio.html +29 -0
  7. package/components/attachment.html +98 -0
  8. package/components/avatar.html +149 -0
  9. package/components/badge.html +62 -0
  10. package/components/breadcrumb.html +159 -0
  11. package/components/bubble.html +77 -0
  12. package/components/button-group.html +98 -0
  13. package/components/button.html +194 -0
  14. package/components/calendar.html +176 -0
  15. package/components/card.html +143 -0
  16. package/components/carousel.html +208 -0
  17. package/components/chart.html +168 -0
  18. package/components/checkbox.html +99 -0
  19. package/components/code-block.html +64 -0
  20. package/components/collapsible.html +90 -0
  21. package/components/combobox.html +237 -0
  22. package/components/command.html +201 -0
  23. package/components/context-menu.html +81 -0
  24. package/components/dialog.html +327 -0
  25. package/components/direction.html +23 -0
  26. package/components/drawer.html +267 -0
  27. package/components/dropdown-menu.html +421 -0
  28. package/components/empty.html +132 -0
  29. package/components/field.html +143 -0
  30. package/components/hover-card.html +111 -0
  31. package/components/input-group.html +91 -0
  32. package/components/input-otp.html +151 -0
  33. package/components/input.html +94 -0
  34. package/components/item.html +208 -0
  35. package/components/kbd.html +45 -0
  36. package/components/label.html +46 -0
  37. package/components/marker.html +41 -0
  38. package/components/menubar.html +137 -0
  39. package/components/message-scroller.html +68 -0
  40. package/components/message.html +95 -0
  41. package/components/navigation-menu.html +233 -0
  42. package/components/pagination.html +160 -0
  43. package/components/popover.html +164 -0
  44. package/components/progress.html +45 -0
  45. package/components/radio-group.html +120 -0
  46. package/components/resizable.html +170 -0
  47. package/components/scroll-area.html +56 -0
  48. package/components/select.html +103 -0
  49. package/components/separator.html +31 -0
  50. package/components/sheet.html +173 -0
  51. package/components/sidebar.html +393 -0
  52. package/components/skeleton.html +36 -0
  53. package/components/slider.html +108 -0
  54. package/components/spinner.html +53 -0
  55. package/components/switch.html +95 -0
  56. package/components/table.html +81 -0
  57. package/components/tabs.html +182 -0
  58. package/components/textarea.html +80 -0
  59. package/components/toaster.html +134 -0
  60. package/components/toggle-group.html +71 -0
  61. package/components/toggle.html +87 -0
  62. package/components/tooltip.html +114 -0
  63. package/dist/theme.css +158 -0
  64. package/dist/ui.html +7923 -0
  65. package/package.json +40 -3
  66. package/theme.css +158 -0
@@ -0,0 +1,114 @@
1
+ <custom-element name="ui-tooltip">
2
+ <script>
3
+ const props = defineProps({
4
+ delay: prop.number().min(0).default(300),
5
+ });
6
+
7
+ const parts = useChildren("ui-tooltip-trigger, ui-tooltip-content");
8
+
9
+ let timer;
10
+
11
+ function tip() {
12
+ return parts.find((part) => part.localName === "ui-tooltip-content");
13
+ }
14
+
15
+ function show(trigger) {
16
+ clearTimeout(timer);
17
+ timer = setTimeout(() => {
18
+ if (!tip().matches(":popover-open")) tip().showPopover({ source: trigger });
19
+ }, props.delay);
20
+ }
21
+
22
+ function hide() {
23
+ clearTimeout(timer);
24
+ if (tip().matches(":popover-open")) tip().hidePopover();
25
+ }
26
+
27
+ function key(event) {
28
+ if (event.key === "Escape") hide();
29
+ }
30
+
31
+ function describe() {
32
+ const text = tip()?.textContent.trim() ?? "";
33
+ for (const trigger of parts.filter((part) => part.localName === "ui-tooltip-trigger"))
34
+ for (const element of trigger.children) element.setAttribute("aria-description", text);
35
+ }
36
+
37
+ observe(describe);
38
+ </script>
39
+
40
+ <style>
41
+ /* A double tap must not zoom the page. Set inside the shadow root, because a page-level
42
+ touch-action does not reach shadow content in iOS Safari. */
43
+ :host,
44
+ * {
45
+ touch-action: manipulation;
46
+ }
47
+ :host {
48
+ display: contents;
49
+ }
50
+ </style>
51
+
52
+ <slot></slot>
53
+ </custom-element>
54
+
55
+ <custom-element name="ui-tooltip-trigger">
56
+ <style>
57
+ :host,
58
+ * {
59
+ touch-action: manipulation;
60
+ }
61
+ :host {
62
+ display: inline-block;
63
+ vertical-align: middle;
64
+ }
65
+ </style>
66
+
67
+ <span part="trigger" onpointerenter="show(host)" onpointerleave="hide()" onfocusin="show(host)" onfocusout="hide()" onkeydown="key(event)"><slot></slot></span>
68
+ </custom-element>
69
+
70
+ <custom-element name="ui-tooltip-content" role="tooltip">
71
+ <script>
72
+ defineProps({
73
+ placement: prop.enum(["top", "bottom", "left", "right"]).default("top"),
74
+ });
75
+
76
+ attrs.popover ??= "manual";
77
+ </script>
78
+
79
+ <style>
80
+ :host,
81
+ * {
82
+ touch-action: manipulation;
83
+ }
84
+ :host {
85
+ margin: 0 0 calc(var(--spacing) * 1);
86
+ padding: calc(var(--spacing) * 1.5) calc(var(--spacing) * 3);
87
+ border: 0;
88
+ border-radius: var(--radius-md);
89
+ background: var(--foreground);
90
+ color: var(--background);
91
+ font-size: var(--text-xs);
92
+ inset: auto;
93
+ height: fit-content;
94
+ max-height: calc(100svh - calc(var(--spacing) * 8));
95
+ overflow-y: auto;
96
+ position-area: top;
97
+ position-try-fallbacks: flip-block;
98
+ }
99
+ :host(:state(attr-placement-is-bottom)) {
100
+ position-area: bottom;
101
+ margin: calc(var(--spacing) * 1) 0 0;
102
+ }
103
+ :host(:state(attr-placement-is-left)) {
104
+ position-area: left;
105
+ margin: 0 calc(var(--spacing) * 1) 0 0;
106
+ }
107
+ :host(:state(attr-placement-is-right)) {
108
+ position-area: right;
109
+ margin: 0 0 0 calc(var(--spacing) * 1);
110
+ }
111
+ </style>
112
+
113
+ <slot></slot>
114
+ </custom-element>
package/dist/theme.css ADDED
@@ -0,0 +1,158 @@
1
+ :root {
2
+ color-scheme: light;
3
+ --radius: 0.625rem;
4
+ --spacing: 0.25rem;
5
+ --text-xs: 0.75rem;
6
+ --text-sm: 0.875rem;
7
+ --text-base: 1rem;
8
+ --text-lg: 1.125rem;
9
+ --text-xl: 1.25rem;
10
+ --text-2xl: 1.5rem;
11
+ --text-3xl: 1.875rem;
12
+ --text-4xl: 2.25rem;
13
+ --leading-tight: 1.25;
14
+ --leading-normal: 1.5;
15
+ --font-weight-normal: 400;
16
+ --font-weight-medium: 500;
17
+ --font-weight-semibold: 600;
18
+ --font-weight-bold: 700;
19
+ --tracking-tight: -0.025em;
20
+ --radius-xs: calc(var(--radius) - 6px);
21
+ --radius-sm: calc(var(--radius) - 4px);
22
+ --radius-md: calc(var(--radius) - 2px);
23
+ --radius-lg: var(--radius);
24
+ --radius-xl: calc(var(--radius) + 4px);
25
+ --radius-2xl: calc(var(--radius) + 8px);
26
+ --radius-full: 9999px;
27
+ --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
28
+ --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
29
+ --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
30
+ --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
31
+ --default-transition-duration: 150ms;
32
+ --default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
33
+ --focus-ring: 0 0 0 2px var(--ring);
34
+ --background: oklch(1 0 0);
35
+ --foreground: oklch(0.145 0 0);
36
+ --card: oklch(1 0 0);
37
+ --card-foreground: oklch(0.145 0 0);
38
+ --popover: oklch(1 0 0);
39
+ --popover-foreground: oklch(0.145 0 0);
40
+ --primary: oklch(0.56 0.21 347);
41
+ --primary-foreground: oklch(0.985 0 0);
42
+ --secondary: oklch(0.97 0 0);
43
+ --secondary-foreground: oklch(0.205 0 0);
44
+ --muted: oklch(0.97 0 0);
45
+ --muted-foreground: oklch(0.5 0 0);
46
+ --accent: oklch(0.97 0 0);
47
+ --accent-foreground: oklch(0.205 0 0);
48
+ --destructive: oklch(0.54 0.22 27);
49
+ --destructive-foreground: oklch(0.985 0 0);
50
+ --border: oklch(0.89 0 0);
51
+ --input: oklch(0.62 0 0);
52
+ --ring: oklch(0.6 0.2 347);
53
+ --chart-1: oklch(0.56 0.21 347);
54
+ --chart-2: oklch(0.58 0.17 5);
55
+ --chart-3: oklch(0.455 0.13 333);
56
+ --chart-4: oklch(0.43 0.17 260);
57
+ --chart-5: oklch(0.55 0.1 226);
58
+ --sidebar: oklch(0.985 0 0);
59
+ --sidebar-foreground: oklch(0.145 0 0);
60
+ --sidebar-primary: oklch(0.56 0.21 347);
61
+ --sidebar-primary-foreground: oklch(0.985 0 0);
62
+ --sidebar-ring: oklch(0.6 0.2 347);
63
+ --sidebar-accent: oklch(0.97 0 0);
64
+ --sidebar-border: oklch(0.89 0 0);
65
+ --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
66
+ --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
67
+ }
68
+
69
+ :root[data-theme="dark"] {
70
+ color-scheme: dark;
71
+ --background: oklch(0.145 0 0);
72
+ --foreground: oklch(0.985 0 0);
73
+ --card: oklch(0.205 0 0);
74
+ --card-foreground: oklch(0.985 0 0);
75
+ --popover: oklch(0.205 0 0);
76
+ --popover-foreground: oklch(0.985 0 0);
77
+ --primary: oklch(0.7 0.19 347);
78
+ --primary-foreground: oklch(0.145 0 0);
79
+ --secondary: oklch(0.269 0 0);
80
+ --secondary-foreground: oklch(0.985 0 0);
81
+ --muted: oklch(0.269 0 0);
82
+ --muted-foreground: oklch(0.708 0 0);
83
+ --accent: oklch(0.269 0 0);
84
+ --accent-foreground: oklch(0.985 0 0);
85
+ --destructive: oklch(0.704 0.191 22.216);
86
+ --destructive-foreground: oklch(0.145 0 0);
87
+ --border: oklch(1 0 0 / 10%);
88
+ --input: oklch(1 0 0 / 40%);
89
+ --ring: oklch(0.6 0.2 347);
90
+ --chart-1: oklch(0.7 0.19 347);
91
+ --chart-2: oklch(0.7 0.17 10);
92
+ --chart-3: oklch(0.6 0.15 320);
93
+ --chart-4: oklch(0.6 0.17 260);
94
+ --chart-5: oklch(0.75 0.11 226);
95
+ --sidebar: oklch(0.205 0 0);
96
+ --sidebar-foreground: oklch(0.985 0 0);
97
+ --sidebar-primary: oklch(0.7 0.19 347);
98
+ --sidebar-primary-foreground: oklch(0.145 0 0);
99
+ --sidebar-ring: oklch(0.6 0.2 347);
100
+ --sidebar-accent: oklch(0.269 0 0);
101
+ --sidebar-border: oklch(1 0 0 / 10%);
102
+ }
103
+
104
+ @media (prefers-color-scheme: dark) {
105
+ :root:not([data-theme="light"]) {
106
+ color-scheme: dark;
107
+ --background: oklch(0.145 0 0);
108
+ --foreground: oklch(0.985 0 0);
109
+ --card: oklch(0.205 0 0);
110
+ --card-foreground: oklch(0.985 0 0);
111
+ --popover: oklch(0.205 0 0);
112
+ --popover-foreground: oklch(0.985 0 0);
113
+ --primary: oklch(0.7 0.19 347);
114
+ --primary-foreground: oklch(0.145 0 0);
115
+ --secondary: oklch(0.269 0 0);
116
+ --secondary-foreground: oklch(0.985 0 0);
117
+ --muted: oklch(0.269 0 0);
118
+ --muted-foreground: oklch(0.708 0 0);
119
+ --accent: oklch(0.269 0 0);
120
+ --accent-foreground: oklch(0.985 0 0);
121
+ --destructive: oklch(0.704 0.191 22.216);
122
+ --destructive-foreground: oklch(0.145 0 0);
123
+ --border: oklch(1 0 0 / 10%);
124
+ --input: oklch(1 0 0 / 40%);
125
+ --ring: oklch(0.6 0.2 347);
126
+ --chart-1: oklch(0.7 0.19 347);
127
+ --chart-2: oklch(0.7 0.17 10);
128
+ --chart-3: oklch(0.6 0.15 320);
129
+ --chart-4: oklch(0.6 0.17 260);
130
+ --chart-5: oklch(0.75 0.11 226);
131
+ --sidebar: oklch(0.205 0 0);
132
+ --sidebar-foreground: oklch(0.985 0 0);
133
+ --sidebar-primary: oklch(0.7 0.19 347);
134
+ --sidebar-primary-foreground: oklch(0.145 0 0);
135
+ --sidebar-ring: oklch(0.6 0.2 347);
136
+ --sidebar-accent: oklch(0.269 0 0);
137
+ --sidebar-border: oklch(1 0 0 / 10%);
138
+ }
139
+ }
140
+
141
+ /* Taps respond at once and a double tap does not zoom. Pinch zoom still works. */
142
+ html {
143
+ touch-action: manipulation;
144
+ }
145
+
146
+ /* iOS Safari only sends clicks for taps on clickable elements, so tapping outside an open popover
147
+ or menu would not close it. Touch screens show no cursor, so this changes nothing visible. */
148
+ @media (pointer: coarse) {
149
+ html {
150
+ cursor: pointer;
151
+ }
152
+ }
153
+
154
+ body {
155
+ background: var(--background);
156
+ color: var(--foreground);
157
+ font-family: var(--font-sans);
158
+ }