@glasshome/ui 1.42.0 → 1.44.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 (153) hide show
  1. package/SPEC.md +8 -5
  2. package/dist/index.js +2 -2
  3. package/dist/lib/anchor-placement.d.ts +4 -0
  4. package/dist/lib/balance-rows.d.ts +10 -4
  5. package/dist/lib/behavior/anchored.d.ts +16 -3
  6. package/dist/lib/behavior/button-root.d.ts +7 -0
  7. package/dist/lib/behavior/collection.d.ts +8 -0
  8. package/dist/lib/behavior/dismiss.d.ts +6 -4
  9. package/dist/lib/behavior/focus-scope.d.ts +9 -1
  10. package/dist/lib/behavior/hide-outside.d.ts +1 -1
  11. package/dist/lib/behavior/layer-stack.d.ts +3 -2
  12. package/dist/lib/behavior/menu.d.ts +62 -0
  13. package/dist/lib/behavior/modal-root.d.ts +2 -0
  14. package/dist/lib/behavior/range.d.ts +44 -0
  15. package/dist/lib/color/color.d.ts +41 -0
  16. package/dist/lib/color/index.d.ts +2 -0
  17. package/dist/lib/color/intl.d.ts +40 -0
  18. package/dist/lib/dock-slot-classes.d.ts +2 -0
  19. package/dist/lib/hold.d.ts +1 -1
  20. package/dist/lib/locale.d.ts +3 -0
  21. package/dist/lib/menu-classes.d.ts +2 -0
  22. package/dist/lib/motion-classes.d.ts +2 -1
  23. package/dist/lib/overlay-classes.d.ts +1 -0
  24. package/dist/lib/scroll-track.d.ts +3 -2
  25. package/dist/lib/section-tokens.d.ts +1 -1
  26. package/dist/lib/segment-classes.d.ts +2 -0
  27. package/dist/lib/shadow-layer.d.ts +0 -45
  28. package/dist/lib/toggle-set.d.ts +44 -0
  29. package/dist/lib/visually-hidden.d.ts +3 -0
  30. package/dist/solid/accordion.d.ts +35 -11
  31. package/dist/solid/avatar.d.ts +8 -4
  32. package/dist/solid/bottom-sheet/bottom-sheet.d.ts +1 -1
  33. package/dist/solid/button.d.ts +5 -4
  34. package/dist/solid/charts.d.ts +1 -1
  35. package/dist/solid/checkbox.d.ts +14 -4
  36. package/dist/solid/collapsible.d.ts +33 -5
  37. package/dist/solid/color-disc.d.ts +1 -1
  38. package/dist/solid/color-slider.d.ts +1 -1
  39. package/dist/solid/color-wheel.d.ts +1 -1
  40. package/dist/solid/context-menu.d.ts +58 -24
  41. package/dist/solid/data-table.d.ts +4 -2
  42. package/dist/solid/dialog-parts.d.ts +8 -8
  43. package/dist/solid/dropdown-menu.d.ts +55 -24
  44. package/dist/solid/empty.d.ts +1 -1
  45. package/dist/solid/form.d.ts +5 -6
  46. package/dist/solid/hover-card.d.ts +65 -9
  47. package/dist/solid/index.d.ts +1 -1
  48. package/dist/solid/index.js +7752 -13493
  49. package/dist/solid/input-group.d.ts +6 -6
  50. package/dist/solid/item.d.ts +1 -1
  51. package/dist/solid/menu-parts.d.ts +175 -24
  52. package/dist/solid/option-card.d.ts +1 -4
  53. package/dist/solid/picker-row.d.ts +2 -0
  54. package/dist/solid/popover.d.ts +77 -12
  55. package/dist/solid/progress.d.ts +11 -3
  56. package/dist/solid/radio-group.d.ts +31 -6
  57. package/dist/solid/responsive-dialog.d.ts +1 -1
  58. package/dist/solid/scroll-area.d.ts +1 -1
  59. package/dist/solid/section-card.d.ts +2 -3
  60. package/dist/solid/select.d.ts +107 -10
  61. package/dist/solid/selection.d.ts +10 -1
  62. package/dist/solid/sheet.d.ts +1 -1
  63. package/dist/solid/sliding-indicator.d.ts +1 -1
  64. package/dist/solid/sonner.d.ts +1 -1
  65. package/dist/solid/toggle.d.ts +11 -3
  66. package/dist/solid/tooltip.d.ts +22 -22
  67. package/dist/tokens/index.js +54 -51
  68. package/dist/{utils-CxAii-e9.js → utils-BbIeGt7o.js} +376 -314
  69. package/package.json +3 -6
  70. package/src/lib/anchor-placement.ts +10 -3
  71. package/src/lib/balance-rows.ts +115 -40
  72. package/src/lib/behavior/anchored.ts +41 -9
  73. package/src/lib/behavior/button-root.tsx +103 -0
  74. package/src/lib/behavior/collection.ts +56 -28
  75. package/src/lib/behavior/dismiss.ts +61 -21
  76. package/src/lib/behavior/focus-scope.ts +75 -9
  77. package/src/lib/behavior/hide-outside.ts +2 -2
  78. package/src/lib/behavior/layer-stack.ts +33 -8
  79. package/src/lib/behavior/menu.ts +462 -0
  80. package/src/lib/behavior/modal-root.tsx +24 -18
  81. package/src/lib/behavior/polymorphic.tsx +1 -1
  82. package/src/lib/behavior/presence.ts +1 -1
  83. package/src/lib/behavior/range.ts +212 -0
  84. package/src/lib/clipboard.ts +2 -3
  85. package/src/lib/color/color.ts +746 -0
  86. package/src/lib/color/index.ts +2 -0
  87. package/src/lib/color/intl.ts +60 -0
  88. package/src/lib/dock-slot-classes.ts +3 -0
  89. package/src/lib/hold.ts +1 -1
  90. package/src/lib/locale.ts +62 -0
  91. package/src/lib/menu-classes.ts +3 -0
  92. package/src/lib/motion-classes.ts +8 -9
  93. package/src/lib/overlay-classes.ts +1 -3
  94. package/src/lib/scroll-track.ts +11 -6
  95. package/src/lib/section-tokens.ts +1 -1
  96. package/src/lib/segment-classes.ts +3 -0
  97. package/src/lib/shadow-layer.ts +0 -118
  98. package/src/lib/toggle-set.ts +133 -0
  99. package/src/lib/visually-hidden.ts +15 -0
  100. package/src/solid/accordion.tsx +294 -20
  101. package/src/solid/area-picker.tsx +4 -4
  102. package/src/solid/avatar.tsx +98 -24
  103. package/src/solid/bottom-sheet/arbitration.ts +4 -11
  104. package/src/solid/bottom-sheet/bottom-sheet.tsx +4 -5
  105. package/src/solid/bottom-sheet/drag-controller.ts +7 -20
  106. package/src/solid/button.tsx +12 -6
  107. package/src/solid/charts.tsx +1 -1
  108. package/src/solid/checkbox.tsx +167 -44
  109. package/src/solid/collapsible.tsx +260 -12
  110. package/src/solid/color-disc.tsx +11 -12
  111. package/src/solid/color-slider.tsx +114 -47
  112. package/src/solid/color-wheel.tsx +137 -39
  113. package/src/solid/context-menu.tsx +285 -94
  114. package/src/solid/data-table.tsx +48 -22
  115. package/src/solid/dialog-parts.tsx +39 -17
  116. package/src/solid/dock.tsx +44 -43
  117. package/src/solid/dropdown-menu.tsx +252 -115
  118. package/src/solid/empty.tsx +1 -1
  119. package/src/solid/entity-selector.tsx +3 -3
  120. package/src/solid/face-toggle.tsx +43 -18
  121. package/src/solid/form.tsx +5 -6
  122. package/src/solid/glyph-tile.tsx +48 -21
  123. package/src/solid/hover-card.tsx +287 -25
  124. package/src/solid/icon-picker.tsx +1 -2
  125. package/src/solid/image-picker.tsx +2 -2
  126. package/src/solid/index.ts +1 -3
  127. package/src/solid/input-group.tsx +2 -2
  128. package/src/solid/item.tsx +1 -1
  129. package/src/solid/menu-parts.tsx +610 -155
  130. package/src/solid/option-card.tsx +7 -13
  131. package/src/solid/picker-row.tsx +5 -1
  132. package/src/solid/popover.tsx +423 -80
  133. package/src/solid/preview-tile.tsx +1 -1
  134. package/src/solid/progress.tsx +84 -15
  135. package/src/solid/radio-group.tsx +271 -34
  136. package/src/solid/responsive-dialog.tsx +1 -1
  137. package/src/solid/schema-form.tsx +1 -6
  138. package/src/solid/scroll-area.tsx +1 -1
  139. package/src/solid/section-card.tsx +3 -4
  140. package/src/solid/select.tsx +939 -95
  141. package/src/solid/selection.tsx +165 -74
  142. package/src/solid/sheet.tsx +1 -1
  143. package/src/solid/slider.tsx +115 -65
  144. package/src/solid/sliding-indicator.tsx +4 -16
  145. package/src/solid/sonner.tsx +1 -1
  146. package/src/solid/tabs.tsx +12 -6
  147. package/src/solid/term.tsx +3 -4
  148. package/src/solid/toggle-group.tsx +34 -101
  149. package/src/solid/toggle.tsx +43 -9
  150. package/src/solid/tooltip.tsx +24 -24
  151. package/src/styles/globals.css +61 -50
  152. package/src/styles/theme.css +12 -6
  153. package/src/tokens/material.ts +11 -2
@@ -1,8 +1,16 @@
1
- import { ColorSlider as KColorSlider } from "@kobalte/core/color-slider";
2
- import type { Color, ColorChannel } from "@kobalte/core/colors";
3
1
  import type { Component } from "solid-js";
4
- import { splitProps } from "solid-js";
2
+ import { createSignal } from "solid-js";
3
+ import { createControllableSignal } from "../lib/behavior/controllable.js";
4
+ import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
5
+ import { alongTrack, createDrag, createRange } from "../lib/behavior/range.js";
6
+ import {
7
+ type Color,
8
+ type ColorChannel,
9
+ COLOR_INTL_TRANSLATIONS,
10
+ parseColor,
11
+ } from "../lib/color/index.js";
5
12
  import { FOCUS_RING } from "../lib/input-classes.js";
13
+ import { readingDirection } from "../lib/locale.js";
6
14
  import { THUMB_CLASS, THUMB_COLOR_RING, THUMB_RAIL_PAD } from "../lib/thumb-classes.js";
7
15
  import { cn } from "../lib/utils.js";
8
16
 
@@ -17,81 +25,140 @@ interface ColorSliderProps {
17
25
  "aria-label"?: string;
18
26
  }
19
27
 
28
+ const rtl = readingDirection === "rtl";
29
+ const START = rtl ? "right" : "left";
30
+ const THUMB_SHIFT = rtl ? "translateX(50%)" : "translateX(-50%)";
31
+ const RED = parseColor("hsl(0, 100%, 50%)");
32
+
33
+ const valueText = (color: Color, channel: ColorChannel) => {
34
+ const formatted = color.formatChannelValue(channel);
35
+ if (channel === "alpha") return formatted;
36
+ if (channel === "hue") {
37
+ const hue = parseColor(`hsl(${color.getChannelValue("hue")}, 100%, 50%)`);
38
+ return `${formatted}, ${hue.getHueName(COLOR_INTL_TRANSLATIONS)}`;
39
+ }
40
+ return `${formatted}, ${color.withChannelValue("alpha", 1).getColorName(COLOR_INTL_TRANSLATIONS)}`;
41
+ };
42
+
20
43
  const ColorSlider: Component<ColorSliderProps> = (props) => {
21
- const [local] = splitProps(props, [
22
- "value",
23
- "defaultValue",
24
- "channel",
25
- "onChange",
26
- "onChangeEnd",
27
- "disabled",
28
- "class",
29
- "aria-label",
30
- ]);
44
+ const disabled = () => props.disabled ?? false;
45
+ const [color, setColor] = createControllableSignal({
46
+ value: () => props.value,
47
+ defaultValue: () => props.defaultValue ?? RED,
48
+ onChange: (next) => props.onChange?.(next),
49
+ });
50
+ const channelRange = () => color().getChannelRange(props.channel);
51
+ const range = createRange({
52
+ values: () => [color().getChannelValue(props.channel)],
53
+ defaultValues: () => [color().getChannelValue(props.channel)],
54
+ min: () => channelRange().minValue,
55
+ max: () => channelRange().maxValue,
56
+ step: () => channelRange().step,
57
+ disabled,
58
+ onChange: ([v = 0]) => setColor(color().withChannelValue(props.channel, v)),
59
+ onChangeEnd: ([v = 0]) => props.onChangeEnd?.(color().withChannelValue(props.channel, v)),
60
+ });
61
+ const percent = () => range.fraction(range.values()[0] ?? 0) * 100;
62
+ const [thumb, setThumb] = createSignal<HTMLElement>();
63
+ let grab = 0;
31
64
 
32
- // Kobalte paints the channel gradient on the (half-thumb padded) track, which
33
- // leaves naked strips at the ends, so we rebuild it on the full-width root.
65
+ const drag = createDrag({
66
+ disabled,
67
+ start: (e, rect) => {
68
+ const at = alongTrack(e, rect);
69
+ if (thumb()?.contains(e.target as Node)) {
70
+ grab = at - percent() / 100;
71
+ } else {
72
+ const { minValue, maxValue } = channelRange();
73
+ grab = 0;
74
+ range.setThumb(0, minValue + at * (maxValue - minValue));
75
+ }
76
+ focusWithoutTracking(thumb());
77
+ },
78
+ move: (e, rect) => range.setThumb(0, range.valueAt(alongTrack(e, rect) - grab)),
79
+ end: range.dragEnd,
80
+ });
81
+
82
+ // The channel gradient runs under the whole root, thumb padding included, so the ends show no bare strip.
34
83
  const gradient = () => {
35
- const color = local.value ?? local.defaultValue;
36
- if (!color) return undefined;
37
- const channel = local.channel;
84
+ const c = color();
85
+ const channel = props.channel;
38
86
  if (channel === "hue") {
39
87
  const stops = [0, 60, 120, 180, 240, 300, 360]
40
- .map((h) => color.withChannelValue("hue", h).toString("css"))
88
+ .map((h) => c.withChannelValue("hue", h).toString("css"))
41
89
  .join(", ");
42
90
  return `linear-gradient(to right, ${stops})`;
43
91
  }
44
- const { minValue, maxValue } = color.getChannelRange(channel);
45
- const start = color.withChannelValue(channel, minValue).toString("css");
46
- const end = color.withChannelValue(channel, maxValue).toString("css");
92
+ const { minValue, maxValue } = c.getChannelRange(channel);
93
+ const start = c.withChannelValue(channel, minValue).toString("css");
94
+ const end = c.withChannelValue(channel, maxValue).toString("css");
47
95
  if (channel === "lightness") {
48
- const middle = color.withChannelValue(channel, (maxValue - minValue) / 2).toString("css");
96
+ const middle = c.withChannelValue(channel, (maxValue - minValue) / 2).toString("css");
49
97
  return `linear-gradient(to right, ${start}, ${middle}, ${end})`;
50
98
  }
51
99
  return `linear-gradient(to right, ${start}, ${end})`;
52
100
  };
53
101
 
102
+ const disabledMark = () => (disabled() ? "" : undefined);
103
+
54
104
  return (
55
- <KColorSlider
56
- value={local.value}
57
- defaultValue={local.defaultValue}
58
- channel={local.channel}
59
- onChange={local.onChange}
60
- onChangeEnd={local.onChangeEnd}
61
- disabled={local.disabled}
105
+ <div
106
+ role="group"
62
107
  data-slot="color-slider"
108
+ data-orientation="horizontal"
109
+ data-disabled={disabledMark()}
63
110
  class={cn(
64
111
  "relative flex w-full touch-none items-center rounded-xl select-none",
65
112
  THUMB_RAIL_PAD,
66
- local.disabled && "cursor-not-allowed opacity-50",
67
- local.class,
113
+ disabled() && "cursor-not-allowed opacity-50",
114
+ props.class,
68
115
  )}
69
116
  style={{ background: gradient() }}
70
117
  >
71
- <KColorSlider.Track
118
+ <div
72
119
  data-slot="color-slider-track"
73
- class={cn("relative h-7 w-full", local.disabled ? "cursor-not-allowed" : "cursor-pointer")}
74
- // Kobalte paints the channel gradient as an inline background here, which
75
- // no class can beat; clearing it inline is what keeps the root's
76
- // full-width gradient the only one.
77
- style={{ background: "none" }}
120
+ data-orientation="horizontal"
121
+ data-disabled={disabledMark()}
122
+ class={cn("relative h-7 w-full", disabled() ? "cursor-not-allowed" : "cursor-pointer")}
123
+ style={{ "forced-color-adjust": "none" }}
124
+ on:pointerdown={drag.onPointerDown}
125
+ on:pointermove={drag.onPointerMove}
126
+ on:pointerup={drag.onPointerUp}
127
+ on:pointercancel={drag.onPointerCancel}
78
128
  >
79
- <KColorSlider.Thumb
129
+ <span
130
+ ref={setThumb}
131
+ role="slider"
80
132
  data-slot="color-slider-thumb"
133
+ data-orientation="horizontal"
134
+ data-disabled={disabledMark()}
135
+ tabIndex={disabled() ? undefined : 0}
136
+ aria-label={props["aria-label"] ?? props.channel}
137
+ aria-valuemin={channelRange().minValue}
138
+ aria-valuemax={channelRange().maxValue}
139
+ aria-valuenow={range.values()[0]}
140
+ aria-valuetext={valueText(color(), props.channel)}
141
+ aria-orientation="horizontal"
142
+ aria-disabled={disabled() || undefined}
81
143
  class={cn(
82
144
  THUMB_CLASS,
83
145
  FOCUS_RING,
84
146
  THUMB_COLOR_RING,
85
147
  "absolute top-0",
86
- local.disabled && "cursor-not-allowed",
148
+ disabled() && "cursor-not-allowed",
87
149
  )}
88
- aria-label={local["aria-label"] ?? local.channel}
89
- style={{ background: "var(--kb-color-current)" }}
90
- >
91
- <KColorSlider.Input />
92
- </KColorSlider.Thumb>
93
- </KColorSlider.Track>
94
- </KColorSlider>
150
+ style={{
151
+ [START]: `calc(${percent()}%)`,
152
+ transform: THUMB_SHIFT,
153
+ "touch-action": "none",
154
+ "forced-color-adjust": "none",
155
+ background: color().toString("css"),
156
+ }}
157
+ on:keydown={(e) => range.keyDown(e, 0)}
158
+ onBlur={range.blur}
159
+ />
160
+ </div>
161
+ </div>
95
162
  );
96
163
  };
97
164
 
@@ -1,7 +1,9 @@
1
- import { ColorWheel as KColorWheel } from "@kobalte/core/color-wheel";
2
- import type { Color } from "@kobalte/core/colors";
3
1
  import type { Component } from "solid-js";
4
- import { splitProps } from "solid-js";
2
+ import { createMemo, createSignal } from "solid-js";
3
+ import { createControllableSignal } from "../lib/behavior/controllable.js";
4
+ import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
5
+ import { createDrag, type RangeKey, rangeKeyOf } from "../lib/behavior/range.js";
6
+ import { type Color, COLOR_INTL_TRANSLATIONS, parseColor } from "../lib/color/index.js";
5
7
  import { FOCUS_RING } from "../lib/input-classes.js";
6
8
  import { THUMB_CLASS, THUMB_COLOR_RING, THUMB_SIZE } from "../lib/thumb-classes.js";
7
9
  import { cn } from "../lib/utils.js";
@@ -20,57 +22,153 @@ interface ColorWheelProps {
20
22
  "aria-label"?: string;
21
23
  }
22
24
 
25
+ const RED = parseColor("hsl(0, 100%, 50%)");
26
+ const PAGE = 15;
27
+ const RING = `conic-gradient(from 90deg, ${Array.from({ length: 13 }, (_, i) => `hsl(${i * 30} 100% 50%)`).join(", ")})`;
28
+
29
+ const mod = (n: number, m: number) => ((n % m) + m) % m;
30
+ const roundToStep = (value: number, step: number) => Math.round(value / step) * step;
31
+ const roundDown = (v: number) => (Math.floor(v) === v ? v - 1 : Math.floor(v));
32
+ const angleOf = (x: number, y: number) => mod((Math.atan2(y, x) * 180) / Math.PI, 360);
33
+
23
34
  const ColorWheel: Component<ColorWheelProps> = (props) => {
24
- const [local] = splitProps(props, [
25
- "value",
26
- "defaultValue",
27
- "onChange",
28
- "onChangeEnd",
29
- "size",
30
- "thickness",
31
- "disabled",
32
- "class",
33
- "aria-label",
34
- ]);
35
- const size = () => local.size ?? 200;
36
- // Kobalte reads `thickness` as a percentage of the radius, so a px thumb
37
- // only fits if the ring is sized from the same number the class resolves to.
38
- // Clamped at the top of that range: past it Kobalte's mask radius goes
39
- // negative and the ring renders as a filled disc.
35
+ const size = () => props.size ?? 200;
36
+ // A percentage of the radius sized to the px thumb; past 100 the mask radius goes negative.
40
37
  const thickness = () =>
41
- local.thickness ?? Math.min(100, Math.ceil((THUMB_SIZE / (size() / 2)) * 100));
38
+ props.thickness ?? Math.min(100, Math.ceil((THUMB_SIZE / (size() / 2)) * 100));
39
+ const disabled = () => props.disabled ?? false;
40
+ const [value, setValue] = createControllableSignal({
41
+ value: () => props.value,
42
+ defaultValue: () => props.defaultValue ?? RED,
43
+ onChange: (next) => props.onChange?.(next),
44
+ });
45
+ const color = createMemo(() => {
46
+ const v = value();
47
+ const space = v.getColorSpace();
48
+ return space === "hsl" || space === "hsb" ? v : v.toFormat("hsl");
49
+ });
50
+ const hue = () => color().getChannelValue("hue");
51
+ const outerRadius = () => size() / 2;
52
+ const thumbRadius = () => ((139.75 - (thickness() / 100) * 70) * outerRadius()) / 140;
53
+ const [thumb, setThumb] = createSignal<HTMLElement>();
54
+ let keyed = false;
55
+
56
+ const setHue = (next: number) => {
57
+ if (disabled()) return;
58
+ const turned = roundToStep(mod(next > 360 ? 0 : next, 360), 1);
59
+ if (hue() !== turned) setValue(color().withChannelValue("hue", turned));
60
+ };
61
+ const increment = (by: number) => {
62
+ const step = Math.max(by, 1);
63
+ const next = hue() + step;
64
+ setHue(roundToStep(mod(next >= 360 ? 0 : next, 360), step));
65
+ };
66
+ const decrement = (by: number) => {
67
+ const step = Math.max(by, 1);
68
+ if (hue() === 0) setHue(roundDown(360 / step) * step);
69
+ else setHue(roundToStep(mod(hue() - step, 360), step));
70
+ };
71
+ const ACTIONS: Record<RangeKey, () => void> = {
72
+ decrease: () => decrement(1),
73
+ increase: () => increment(1),
74
+ pageDown: () => decrement(PAGE),
75
+ pageUp: () => increment(PAGE),
76
+ first: () => setHue(0),
77
+ last: () => setHue(360),
78
+ };
79
+
80
+ const pointerHue = (e: PointerEvent, rect: DOMRect) =>
81
+ angleOf(e.clientX - rect.left - rect.width / 2, e.clientY - rect.top - rect.height / 2);
82
+
83
+ const drag = createDrag({
84
+ disabled,
85
+ start: (e, rect) => {
86
+ focusWithoutTracking(thumb());
87
+ setHue(pointerHue(e, rect));
88
+ },
89
+ move: (e, rect) => setHue(pointerHue(e, rect)),
90
+ end: () => props.onChangeEnd?.(color()),
91
+ });
92
+
93
+ const onKeyDown = (e: KeyboardEvent) => {
94
+ const key = rangeKeyOf(e);
95
+ if (!key || disabled()) return;
96
+ e.preventDefault();
97
+ e.stopPropagation();
98
+ keyed = true;
99
+ ACTIONS[key]();
100
+ };
101
+ const onBlur = () => {
102
+ if (!keyed) return;
103
+ keyed = false;
104
+ props.onChangeEnd?.(color());
105
+ };
106
+
107
+ const disabledMark = () => (disabled() ? "" : undefined);
108
+ const place = () => {
109
+ const a = (hue() * Math.PI) / 180;
110
+ return {
111
+ x: outerRadius() + thumbRadius() * Math.cos(a),
112
+ y: outerRadius() + thumbRadius() * Math.sin(a),
113
+ };
114
+ };
42
115
 
43
116
  return (
44
- <KColorWheel
45
- value={local.value}
46
- defaultValue={local.defaultValue}
47
- onChange={local.onChange}
48
- onChangeEnd={local.onChangeEnd}
49
- thickness={thickness()}
50
- disabled={local.disabled}
117
+ <div
118
+ role="group"
51
119
  data-slot="color-wheel"
120
+ data-disabled={disabledMark()}
52
121
  class={cn(
53
122
  "relative touch-none select-none",
54
- local.disabled && "cursor-not-allowed opacity-50",
55
- local.class,
123
+ disabled() && "cursor-not-allowed opacity-50",
124
+ props.class,
56
125
  )}
57
126
  style={{ width: `${size()}px`, height: `${size()}px` }}
58
127
  >
59
- <KColorWheel.Track
128
+ <div
60
129
  data-slot="color-wheel-track"
61
- class={cn("h-full w-full", local.disabled ? "cursor-not-allowed" : "cursor-pointer")}
130
+ data-disabled={disabledMark()}
131
+ class={cn("h-full w-full", disabled() ? "cursor-not-allowed" : "cursor-pointer")}
132
+ style={{
133
+ "touch-action": "none",
134
+ "forced-color-adjust": "none",
135
+ background: RING,
136
+ "clip-path": "circle(50%)",
137
+ mask: `radial-gradient(#0000 ${70 - (thickness() / 100) * 70}%, #000 ${70.5 - (thickness() / 100) * 70}%)`,
138
+ }}
139
+ on:pointerdown={drag.onPointerDown}
140
+ on:pointermove={drag.onPointerMove}
141
+ on:pointerup={drag.onPointerUp}
142
+ on:pointercancel={drag.onPointerCancel}
62
143
  >
63
144
  {/* Always a circle: the thumb rides a circular track, theme corner radius looks broken there. */}
64
- <KColorWheel.Thumb
145
+ <span
146
+ ref={setThumb}
147
+ role="slider"
65
148
  data-slot="color-wheel-thumb"
149
+ data-disabled={disabledMark()}
150
+ tabIndex={disabled() ? undefined : 0}
151
+ aria-label={props["aria-label"] ?? "Hue"}
152
+ aria-valuemin={0}
153
+ aria-valuemax={360}
154
+ aria-valuenow={hue()}
155
+ aria-valuetext={`${color().formatChannelValue("hue")}, ${color().getHueName(COLOR_INTL_TRANSLATIONS)}`}
156
+ aria-disabled={disabled() || undefined}
66
157
  class={cn(THUMB_CLASS, FOCUS_RING, THUMB_COLOR_RING, "rounded-full")}
67
- aria-label={local["aria-label"] ?? "Hue"}
68
- style={{ background: "var(--kb-color-current)" }}
69
- >
70
- <KColorWheel.Input />
71
- </KColorWheel.Thumb>
72
- </KColorWheel.Track>
73
- </KColorWheel>
158
+ style={{
159
+ position: "absolute",
160
+ left: `${place().x}px`,
161
+ top: `${place().y}px`,
162
+ transform: "translate(-50%, -50%)",
163
+ "forced-color-adjust": "none",
164
+ "touch-action": "none",
165
+ background: color().toString("css"),
166
+ }}
167
+ on:keydown={onKeyDown}
168
+ onBlur={onBlur}
169
+ />
170
+ </div>
171
+ </div>
74
172
  );
75
173
  };
76
174